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. Qt Signal mapper and sending QLabel by reference and OpenCv 2
Forum Updated to NodeBB v4.3 + New Features

Qt Signal mapper and sending QLabel by reference and OpenCv 2

Scheduled Pinned Locked Moved General and Desktop
20 Posts 2 Posters 5.4k 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
    RamzyKaram92
    wrote on last edited by
    #9

    Okay,.. i'll explain
    there is a Qmainwindow that open when i press on an action in the menu bar of the original mainwindow, there is a button says Start and a QLabel to view image - there will be a label for status bar but not implemented yet - user click the button, a timer begin to count, when it times out, the connect - i'll get straight to explaining the SLOT - will activate a method that takes a frame and draw some boxes using Opencv methods, then convert this frame to QImage and show it on the label.
    click signal - > activate timer -> call slot -> query frame -> view it on a passed by reference label.
    this is the first part in my project, i already finished it in Visual studio, but Qt is much more interesting, there is python and c++ ♥
    i'm grateful for all the help here))))

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

      Then my earlier suggestions still stand. Keep the image processing in BinaryImage and emit the QPixmap when ready. It really doesn't need know about that QLabel.

      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
      • R Offline
        R Offline
        RamzyKaram92
        wrote on last edited by
        #11

        but how can i update the label, and if the QPixmap will be the return type of a method, how would i keep calling it in a SLOT which is void ?!
        i use the timer to manage the GUI, cause i don't want things to happen fast and make the GUI not responding

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

          I didn't suggest to make QPixmap the return type of anything. Use a signal that looks like:

          @
          signals:
          void newPixmapReady(const QPixmap& pixmap);
          @

          If you don't want to lock your GUI thread, you can get some inspiration from the Mandelbrot example

          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
          • R Offline
            R Offline
            RamzyKaram92
            wrote on last edited by
            #13

            as far as i know that "connect" only accept signal and slot with the same parameters, but there is no timeout() with QPixmap ?!
            that's why i use SignalMapper and it doesn't work at all for me, i feel that i've a misunderstanding about the SignalMapper xD

            also none of the connect statements that i wrote in the code have worked

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

              It's more about the design. Your timer should be connected to that slot that does the processing, then from this slot emit a signal with the QPixmap

              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
              • R Offline
                R Offline
                RamzyKaram92
                wrote on last edited by
                #15

                but still timers doesn't work in the code up there, is there some problem in they way i made them ?!

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

                  You should really first cleanup the code. Using a QSignalMapper for that task is just an overkill.

                  Anyway, one of the thing is that you are mapping the mapper to the widget which is not the way it's supposed to work. Have a look at QSignalMapper's documentation, there's an example of how it works.

                  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
                  • R Offline
                    R Offline
                    RamzyKaram92
                    wrote on last edited by
                    #17

                    yeah, you're right, sorry for making it too long, any technical design recommendation about things i can have a look at else the Mandelbrot example ?!

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

                      The documentation (Qt 5 latest version) of QThread, you'll see the various implementation possibilities. Then don't try to do everything at once. First get your image on the widget, then move that code to a worker object. Also, since you want to do it at regular interval, why not simply use a QTimer ?

                      Hope it helps

                      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
                      • R Offline
                        R Offline
                        RamzyKaram92
                        wrote on last edited by
                        #19

                        yup, thanks, i'm reading a book about QT Design Patterns, i think i should learn it in a better way

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

                          Good book, there are several that you can learn from

                          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

                          • Login

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