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. How to break QGraphicsScene into fragments?
QtWS25 Last Chance

How to break QGraphicsScene into fragments?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 534 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by Mikeeeeee
    #1

    Hi!
    I'm downloading QGraphicsScene from .SVG file.
    How to break QGraphicsScene into fragments?

    And is it possible to save QGraphicsScene fragmentally without linking into a single fragment? I keep so:

            QString newPath = QFileDialog::getSaveFileName(this, trUtf8("Save SVG"),
                path, tr("SVG files (*.svg)"));
    
            if (newPath.isEmpty())
                return;
    
            path = newPath;
    
            QSvgGenerator generator;        
            generator.setFileName(path);   
            generator.setSize(QSize(scene->width(), scene->height()));  
            generator.setViewBox(QRect(0, 0, scene->width(), scene->height())); 
            generator.setTitle(trUtf8("SVG Example"));                        
            generator.setDescription(trUtf8("File created by SVG Example"));    
    
            QPainter painter;
            painter.begin(&generator);  
            scene->render(&painter);   
            painter.end(); 
    

    I lood so:

    void Paint::on_loadButton_clicked() //load scene
    {
        QString newPath = QFileDialog::getOpenFileName(this, trUtf8("Open SVG"),
                                                       path, tr("SVG files (*.svg)"));
    
        if (newPath.isEmpty())
                return;
    
            path = newPath;
            scene->clear();
    
            //QSvgRenderer myRenderer;
            QSvgRenderer* myRenderer = new QSvgRenderer();
            myRenderer->load(path);
            //scene->setSceneRect(myRenderer->viewBoxF());
            QGraphicsSvgItem *myItem = new QGraphicsSvgItem();
            myItem->setSharedRenderer(myRenderer);
            scene->addItem(myItem);
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by fragments ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        After saving to SVG, all elements drawn separately are combined into one element. If you open SVG the Coreldraw, you can also see that all the individual elements are grouped into one large element.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mikeeeeee
          wrote on last edited by
          #4

          In CorelDRAW calls to cancel the grouping.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Then you'll have to implement that yourself. The render method won't do that for you.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            SGaistS 1 Reply Last reply
            1
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #6

              Is it possible to save in SVG so that all fragments are not combined into one?

              1 Reply Last reply
              0
              • SGaistS SGaist

                Then you'll have to implement that yourself. The render method won't do that for you.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Quoting myself:
                @SGaist said in How to break QGraphicsScene into fragments?:

                Then you'll have to implement that yourself. The render method won't do that for you.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                • Login

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