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. QGraphicsSvg
Forum Updated to NodeBB v4.3 + New Features

QGraphicsSvg

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 548 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Ra_J
    wrote on last edited by
    #1

    hi,
    I'm loading a complete SVG file to graphicsView.
    Below is the code which is working fine.
    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsSvgItem *item = new QGraphicsSvgItem("C://svg//deckmain.svg");
    scene->addItem(item);
    scene->setBackgroundBrush(Qt::gray);
    ui->graphicsView->setScene(scene);
    item->setZValue(0);
    ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
    ui->graphicsView->show();

    ===
    I want to access layers , Path objects created in SVG. So i can change color, select the object with mouse. hide ON/OFF of layers and objects in the file.

    Please someone can guide me.

    Thanks,

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      this may be the example you want to have a peek at
      https://doc.qt.io/qt-5/qtwidgets-graphicsview-elasticnodes-example.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ra_J
        wrote on last edited by
        #3

        Thanks. I need to access layers and elements by using SVG file

        eyllanescE 1 Reply Last reply
        0
        • R Ra_J

          Thanks. I need to access layers and elements by using SVG file

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @Ra_J Qt does not have the ability to do that. I recommend you look for another library that is used to manipulate the svg since Qt only serves to render.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          1
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @Ra_J You cannot manipulate individual SVG elements in QGraphicsSvgItem. However, you can call setElementId() and only display a sub-element in the Item. Create multiple QGraphicsSvgItems and set a different element ID for each.

            See the example code at https://doc.qt.io/qt-5/qgraphicssvgitem.html

            You can then:

            • Call QGraphicsItem::setVisible() to show/hide an item.
            • Apply QGraphicsColorizeEffect to change the colour of an item.

            To make this work, you probably need to re-organize your SVG file a bit.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            R 1 Reply Last reply
            2
            • JKSHJ JKSH

              @Ra_J You cannot manipulate individual SVG elements in QGraphicsSvgItem. However, you can call setElementId() and only display a sub-element in the Item. Create multiple QGraphicsSvgItems and set a different element ID for each.

              See the example code at https://doc.qt.io/qt-5/qgraphicssvgitem.html

              You can then:

              • Call QGraphicsItem::setVisible() to show/hide an item.
              • Apply QGraphicsColorizeEffect to change the colour of an item.

              To make this work, you probably need to re-organize your SVG file a bit.

              R Offline
              R Offline
              Ra_J
              wrote on last edited by
              #6

              @JKSH Thanks, I will try this. I m new to QT so finding it difficult. You are right need to organize SVG file as per requirement.

              1 Reply Last reply
              0

              • Login

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