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. Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene
Forum Updated to NodeBB v4.3 + New Features

Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 1.2k Views 2 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.
  • S Offline
    S Offline
    saurabh162
    wrote on last edited by
    #9

    @JonB many many thanks for answer....I will try what you suggest and will update you ..Thanks :)

    JonBJ 1 Reply Last reply
    0
    • S saurabh162

      @JonB many many thanks for answer....I will try what you suggest and will update you ..Thanks :)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #10

      @saurabh162
      It's a bit ugly, but like I said if you don't care the absolute minimum change to just try and see if you get what you want would be:

      view->view()->setScene(scene);
      view->view()->repaint();
      triggerSignalForScreenShot();
      

      Does that at least do what you want, at least then I understand. Though I still think the QGraphicsView::render() call to produce a QImage would seem to me what you really ought be doing.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saurabh162
        wrote on last edited by saurabh162
        #11

        @JonB once again thanks for your response. I have tried following code to do what you suggested

        view->view()->setScene(scene);
         view->show();
          QPrinter printer(QPrinter::HighResolution);
          printer.pageLayout().pageSize();
         QPainter painter(&printer);
        
         // print, fitting the viewport contents into a full page
          view->render(&painter);
          triggerSignalForScreenShot();
        

        but still I getting the result/problem as mentioned above.

        triggerSignalForScreenShot()
        

        is user defined signal which I connect to its slot using :

        connect(this,&MainWindow::triggerSignalForScreenShot,
                      this, &MainWindow::sceneChanged);
        

        and slot I defined as follows:

        void MainWindow::sceneChanged( )
        {
            shootScreen();
            saveScreenshot();
        }
        

        Thanks !! and kindly inform me if you need any other information or if I am making any mistake.

        JonBJ 1 Reply Last reply
        0
        • S saurabh162

          @JonB once again thanks for your response. I have tried following code to do what you suggested

          view->view()->setScene(scene);
           view->show();
            QPrinter printer(QPrinter::HighResolution);
            printer.pageLayout().pageSize();
           QPainter painter(&printer);
          
           // print, fitting the viewport contents into a full page
            view->render(&painter);
            triggerSignalForScreenShot();
          

          but still I getting the result/problem as mentioned above.

          triggerSignalForScreenShot()
          

          is user defined signal which I connect to its slot using :

          connect(this,&MainWindow::triggerSignalForScreenShot,
                        this, &MainWindow::sceneChanged);
          

          and slot I defined as follows:

          void MainWindow::sceneChanged( )
          {
              shootScreen();
              saveScreenshot();
          }
          

          Thanks !! and kindly inform me if you need any other information or if I am making any mistake.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #12

          @saurabh162 said in Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene:

          view->render(&painter);
          triggerSignalForScreenShot();

          As per the docs this renders the view into the painter you pass to render(), from which it says you can produce a QImage. I have no idea what you think you are doing by ignoring this and calling your original triggerSignalForScreenShot(), what does that have to do with it?

          I also suggested you try the simplest current "fix" by putting in a view->view()->repaint(); initially and seeing that delivers what you want, but you don't seem to have looked at that.

          I leave it to you now, I have helped all I can.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            saurabh162
            wrote on last edited by saurabh162
            #13

            @JonB Thank you !! Actually I have tried view->view()->repaint(); solution provided by you. but it did not help and after that I have tried solution I have pasted in my previous post.

            And about " triggerSignalForScreenShot()" signal I have used because I did not understand how I can pass QImage to render() so that it produce image of screen(Sorry I am newbie in Qt).

            But many thanks for your help ..I will now try/see how i can pass QImage object in render() function. Thank you !!

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

              I am still curious about your need to do the capture of the shown image for comparison rather that do the comparison directly with the image you rebuilt from the camera data.

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

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                I am still curious about your need to do the capture of the shown image for comparison rather that do the comparison directly with the image you rebuilt from the camera data.

                S Offline
                S Offline
                saurabh162
                wrote on last edited by
                #15

                @SGaist sorry I could not understand your question....whether you want to ask, why I want to capture image using camera ? instead of directly comparing images with my reference images directly ?

                SGaistS 1 Reply Last reply
                0
                • S Offline
                  S Offline
                  saurabh162
                  wrote on last edited by
                  #16

                  @JonB @ChrisW67 @SGaist ...I am now able to save snapshot of image I display using "QGraphicsScene" using method mentioned by @JonB .

                  In order to save image in .png format. i have used following code.

                  // Save rendered image in a .png file

                  ```
                  

                  QImage image(11000,7000, QImage::Format_RGB32);

                  QPainter painter(&image);
                  scene->render(&painter);
                  painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
                  image.mirrored().save("output.png");
                  
                  
                  many thanks for your help !!
                  1 Reply Last reply
                  0
                  • S saurabh162

                    @SGaist sorry I could not understand your question....whether you want to ask, why I want to capture image using camera ? instead of directly comparing images with my reference images directly ?

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

                    @saurabh162 said in Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene:

                    @SGaist sorry I could not understand your question....whether you want to ask, why I want to capture image using camera ? instead of directly comparing images with my reference images directly ?

                    No no, I am wondering about the "capture the scene" step rather than directly save the built image.

                    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
                    0
                    • S Offline
                      S Offline
                      saurabh162
                      wrote on last edited by
                      #18

                      @SGaist Capturing image(pattern provided by DMDs(Digital micromirror device)) is important in our case to adjust output from DMDs ( feedback loop ) which will be connected to camera responsible to take pictures on screen.

                      We cannot give feedback to DMDs directly from our PC due to technical reasons...please inform me if i have not answered your question....Thanks !!

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

                        You are at the wrong end of the system for my question.

                        I have no issue with the act of capturing that image for your feedback loop. My question is really, why do need to the detour through the painting of the QGraphicsScene rather than simply save the image you built from the camera to disk ? That would likely give you a higher quality image.

                        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