Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsSvgItem problem with margins
QtWS25 Last Chance

QGraphicsSvgItem problem with margins

Scheduled Pinned Locked Moved Solved General and Desktop
svgqgraphicssvgitepositioningmargins
9 Posts 3 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kjnm
    wrote on 24 Jul 2018, 14:42 last edited by
    #1

    Hello I'am running code of example svgviewer:
    http://doc.qt.io/qt-5/qtsvg-svgviewer-example.html
    I have got svg file. It look like this (it have got margins)
    0_1532442703177_Screen Shot 2018-07-24 at 16.27.29.png

    And it i run code of example svg viewer it look like this:
    0_1532442971521_Screen Shot 2018-07-24 at 16.26.44.png

    How can I render svg file with margins?

    1 Reply Last reply
    1
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 24 Jul 2018, 19:25 last edited by
      #2

      I don't see a difference in your two pictures. Remember that QSvg only supports a subset of the complete svg features - see https://doc.qt.io/qt-5.11/svgrendering.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 24 Jul 2018, 20:29 last edited by
        #3

        Hi
        Could u link image here ?

        1 Reply Last reply
        1
        • K Offline
          K Offline
          kjnm
          wrote on 25 Jul 2018, 07:47 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • K Offline
            K Offline
            kjnm
            wrote on 25 Jul 2018, 07:57 last edited by
            #5

            link to svg file
            In this page svg file is showing similar to svgViewer-Example but if I open this file by firefox, chrome or other svgViewer app it look like picture 1.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 25 Jul 2018, 08:16 last edited by
              #6

              Hi
              Thank for upload.
              Looking at
              http://svgur.com/s/7XB
              There is no build in margins.

              alt text

              what is see in svg viewer is just that svg page size is so big that it leaves no empty space around it
              as its bigger than window can be.

              if you scale the image slightly , it looks like
              alt text

              1 Reply Last reply
              1
              • K Offline
                K Offline
                kjnm
                wrote on 25 Jul 2018, 08:16 last edited by
                #7
                This post is deleted!
                M 1 Reply Last reply 25 Jul 2018, 08:17
                0
                • K kjnm
                  25 Jul 2018, 08:16

                  This post is deleted!

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 25 Jul 2018, 08:17 last edited by
                  #8

                  @kjnm
                  Its just due to it being very big default. ( the page size)

                  Try this one
                  https://www.dropbox.com/s/t3z6yealewmercd/7XB_smaller.svg?dl=0

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 25 Jul 2018, 08:50 last edited by mrjj
                    #9

                    Hi
                    Seem you just want to paint it using a border.
                    Not having a border inside image.
                    That you can easy do when painting it.

                    Like

                    void MiniSVG::paintEvent(QPaintEvent* ) {
                      QPainter p(this);
                      QSvgRenderer r; // this would normally be a member..
                      r.load(QString(":/7XB_smaller.svg"));
                      r.render(&p, rect().adjusted(64, 64, -64, -64));
                    }
                    
                    

                    alt text

                    sample to play with
                    https://www.dropbox.com/s/7a9t5ywrpmagxjd/drawsvg.zip?dl=0


                    if its only this image u need this for, you can also just change page size. ( view box)

                    alt text

                    that should work too.

                    1 Reply Last reply
                    1

                    9/9

                    25 Jul 2018, 08:50

                    • Login

                    • Login or register to search.
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved