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. Signals and slots or whatever
Qt 6.11 is out! See what's new in the release blog

Signals and slots or whatever

Scheduled Pinned Locked Moved Unsolved General and Desktop
71 Posts 6 Posters 39.1k 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.
  • J Offline
    J Offline
    jrod2much
    wrote on last edited by jrod2much
    #21

    I think I found it:
    cccmodule.h

    class CccModule : public MonModule
    {
    public:
        CccModule(Interpreter *interpreter);
        ~CccModule(); //Is this the constructor?
    
        virtual bool render(uint32_t fourcc, const void *args[]);
        virtual bool command(const QStringList &argv);
        virtual void paramChange();
    
    

    There are no instantiations in the ui file

    J.HilkJ 1 Reply Last reply
    0
    • J jrod2much

      I think I found it:
      cccmodule.h

      class CccModule : public MonModule
      {
      public:
          CccModule(Interpreter *interpreter);
          ~CccModule(); //Is this the constructor?
      
          virtual bool render(uint32_t fourcc, const void *args[]);
          virtual bool command(const QStringList &argv);
          virtual void paramChange();
      
      

      There are no instantiations in the ui file

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #22

      @jrod2much
      you should refresh your c++ skills

      https://www.tutorialspoint.com/cplusplus/cpp_constructor_destructor.htm

      what you're pointing out is the destructor.

      Also, to use QObject::connet your class needs to be a sublass of QObject somewhere. I don't know the context of MonModule but make sure that QObject is somere the baseclass in the hirachy.

      Also you should add the Q_Object macro in the header filke, as you're planning to use signals.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      J 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        @jrod2much
        you should refresh your c++ skills

        https://www.tutorialspoint.com/cplusplus/cpp_constructor_destructor.htm

        what you're pointing out is the destructor.

        Also, to use QObject::connet your class needs to be a sublass of QObject somewhere. I don't know the context of MonModule but make sure that QObject is somere the baseclass in the hirachy.

        Also you should add the Q_Object macro in the header filke, as you're planning to use signals.

        J Offline
        J Offline
        jrod2much
        wrote on last edited by
        #23

        @J.Hilk Alright, I have added the Q_OBJECT macro to the header. I found the header and source of MonModule if you'd like to take a look.
        monmodule.h

        #define MAX_MONMODULES 0x40 // this should be way more than neeeded....
        
        class MonModule;
        class Interpreter;
        class Parameter;
        class Renderer;
        
        typedef MonModule *(*NewMonModuleFunc)(Interpreter *);
        typedef QList <MonModule *> MonModules;
        
        
        #define MON_MODULE(module) \
            MonModule *newFunc ## module(Interpreter *interpreter) {\
                return new module(interpreter); } \
            MonModuleUtil g_register ## module(newFunc ## module);
        
        
        class MonModule
        {
        public:
            MonModule(Interpreter *interpreter);
            virtual ~MonModule();
        
            virtual bool render(uint32_t fourcc, const void *args[]);
            virtual bool command(const QStringList &argv);
            virtual void paramChange();
        
        protected:
            bool pixyParameterChanged(const QString &id, QVariant *val=NULL);
            bool pixymonParameterChanged(const QString &id, QVariant *val=NULL);
            QVariant pixyParameter(const QString &id);
            QVariant pixymonParameter(const QString &id);
        
            Interpreter *m_interpreter;
            Renderer *m_renderer;
        };
        
        
        struct MonModuleUtil
        {
            MonModuleUtil(NewMonModuleFunc func)
            {
                m_modules[m_index++] = func;
            }
        
            static void createModules(MonModules *modules, Interpreter *interpreter)
            {
                for (uint i=0; i<m_index; i++)
                    modules->push_back((*m_modules[i])(interpreter));
            }
        
            static void destroyModules(MonModules *modules)
            {
                // delete modules in reverse order
                for (int i=modules->size()-1; i>=0; i--)
                    delete (*modules)[i];
            }
        
            static NewMonModuleFunc m_modules[MAX_MONMODULES];
            static uint m_index;
            static Interpreter *m_interpreter;
        };
        
        void cprintf(const char *format, ...);
        
        

        monmodule.cpp

        NewMonModuleFunc MonModuleUtil::m_modules[MAX_MONMODULES];
        unsigned int MonModuleUtil::m_index = 0;
        Interpreter *MonModuleUtil::m_interpreter = NULL;
        
        
        
        MonModule::MonModule(Interpreter *interpreter)
        {
            m_interpreter = interpreter;
            m_renderer = m_interpreter->m_renderer;
            MonModuleUtil::m_interpreter = interpreter;
        
        }
        
        MonModule::~MonModule()
        {
        }
        
        bool MonModule::render(uint32_t fourcc, const void *args[])
        {
            return false;
        }
        
        bool MonModule::command(const QStringList &argv)
        {
            return false;
        }
        
        void MonModule::paramChange()
        {
        }
        
        bool MonModule::pixyParameterChanged(const QString &id, QVariant *val)
        {
            QMutexLocker lock(m_interpreter->m_pixyParameters.mutex());
            Parameter *param = m_interpreter->m_pixyParameters.parameter(id);
            if (param && val)
                *val = param->value();
            if (param && param->dirty())
                return true;
            return false;
        }
        
        bool MonModule::pixymonParameterChanged(const QString &id, QVariant *val)
        {
            QMutexLocker lock(m_interpreter->m_pixymonParameters->mutex());
            Parameter *param = m_interpreter->m_pixymonParameters->parameter(id);
            if (param && val)
                *val = param->value();
            if (param && param->dirty())
                return true;
            return false;
        }
        
        QVariant MonModule::pixyParameter(const QString &id)
        {
            return m_interpreter->m_pixyParameters.value(id);
        }
        
        QVariant MonModule::pixymonParameter(const QString &id)
        {
            return m_interpreter->m_pixymonParameters->value(id);
        }
        
        
        void cprintf(const char *format, ...)
        {
            char buffer[256];
            va_list args;
            va_start(args, format);
            vsnprintf(buffer, 256, format, args);
            MonModuleUtil::m_interpreter->cprintf(buffer);
            va_end(args);
        }
        
        
        1 Reply Last reply
        0
        • J jrod2much

          Welcome to my world haha. I don't know how it changes, but it does because I set a printf statement to print it every time the program runs through that section of code and it changes.

          Can't we just make it emit the value? I'm not sure I understand anything about the emit function but it sounds like it might work.

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #24

          @jrod2much said in Signals and slots or whatever:

          I set a printf statement to print it every time the program runs through that section of code and it changes.

          Ok, baby steps. Can you put a breakpoint in that section of code and post us the stack trace you see when it gets hit?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          J 1 Reply Last reply
          0
          • VRoninV VRonin

            @jrod2much said in Signals and slots or whatever:

            I set a printf statement to print it every time the program runs through that section of code and it changes.

            Ok, baby steps. Can you put a breakpoint in that section of code and post us the stack trace you see when it gets hit?

            J Offline
            J Offline
            jrod2much
            wrote on last edited by jrod2much
            #25

            @VRonin
            So, I have placed many breakpoints in many places and the program does not terminate at all. The value of m_palette[i] only prints to the output once I manually exit the application running.
            The good part is that if I make many changes to m_palette[i], then they all print out in list form. The bad part is that for some reason, the break points Arent being triggered. I took the time to read up on breakpoint implementation so I don't think I am doing it wrong, but nothing is triggering the breakpoints.

            VRoninV 1 Reply Last reply
            0
            • J jrod2much

              @VRonin
              So, I have placed many breakpoints in many places and the program does not terminate at all. The value of m_palette[i] only prints to the output once I manually exit the application running.
              The good part is that if I make many changes to m_palette[i], then they all print out in list form. The bad part is that for some reason, the break points Arent being triggered. I took the time to read up on breakpoint implementation so I don't think I am doing it wrong, but nothing is triggering the breakpoints.

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #26

              @jrod2much said in Signals and slots or whatever:

              if I make many changes to m_palette[i]

              How are you making that change?

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              J 1 Reply Last reply
              0
              • VRoninV VRonin

                @jrod2much said in Signals and slots or whatever:

                if I make many changes to m_palette[i]

                How are you making that change?

                J Offline
                J Offline
                jrod2much
                wrote on last edited by jrod2much
                #27

                @VRonin So the application is made to run a camera that detects objects. For instance, you can shoot a live video feed, then create a "signature" by selecting the signature option, the frame freezes, and you can use your mouse to highlight an area on the video feed, lets say a red rubber ball. Then the application stores that data and any time a red rubber ball comes into the live video feed, the application tracks it. The application is capable of storing up to 7 different signatures. Hence the m_palette[i]. If you want to read more on it, the camera is called PixyCam 2 and the application it comes with is called PixyMon.

                What I have done here and for the last 2 weeks is tried to take the open source application code that is built on Qt, and add a textBrowser that can display the current signature RGB code. I have found the data variable for the first signature (m_palette[0]). But the application is very complex for a beginner like me and frankly, I thought it would be easier of a task so that I can continue with my project.

                So when I 'make changes' I am just setting a new Signature 1 on the application as it runs.

                1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #28

                  ok, one last try, add Q_ASSERT(false); after the m_palette[i] = m_signatures[i].m_rgb;. this will force your program to crash, when it does, look at the stack trace and post it here please

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  J 1 Reply Last reply
                  0
                  • VRoninV VRonin

                    ok, one last try, add Q_ASSERT(false); after the m_palette[i] = m_signatures[i].m_rgb;. this will force your program to crash, when it does, look at the stack trace and post it here please

                    J Offline
                    J Offline
                    jrod2much
                    wrote on last edited by jrod2much
                    #29

                    @VRonin You are going to hate me Ronin. I have searched all over the internet, I am 99% sure that Qt Creator does not have a stack trace. There are a bunch of forums saying I have to add a huge amount of code to the debug library in order to create a stack trace and I don't think I am skilled enough to do this.

                    Here is the Application Output if that is what you mean by stack trace, but it does not seem helpful:
                    09:51:55: Starting C:\Users\rodriguez\Desktop\pixy2-master\src\host\build-pixymon-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\PixyMon...
                    ASSERT: "false" in file ..\pixymon\cccmodule.cpp, line 155
                    QObject::killTimers: timers cannot be stopped from another thread
                    09:52:01: C:/Users/rodriguez/Desktop/pixy2-master/src/host/build-pixymon-Desktop_Qt_5_2_1_MinGW_32bit-Debug/debug/PixyMon exited with code 3

                    The Q_ASSERT(false); did work. In fact, it worked instantly. It closes the program as soon as the program opens and loads without me pressing anything.

                    Honestly, I did not think that such a simple thing as printing a value to the UI would be so difficult. I'm baffled. Is there any way around this that you can think of. I tried to make a global variable to carry the data of m_palette[0] to the Mainwindow.cpp but obviously even that is drawing an error…

                    VRoninV 1 Reply Last reply
                    0
                    • J jrod2much

                      @VRonin You are going to hate me Ronin. I have searched all over the internet, I am 99% sure that Qt Creator does not have a stack trace. There are a bunch of forums saying I have to add a huge amount of code to the debug library in order to create a stack trace and I don't think I am skilled enough to do this.

                      Here is the Application Output if that is what you mean by stack trace, but it does not seem helpful:
                      09:51:55: Starting C:\Users\rodriguez\Desktop\pixy2-master\src\host\build-pixymon-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\PixyMon...
                      ASSERT: "false" in file ..\pixymon\cccmodule.cpp, line 155
                      QObject::killTimers: timers cannot be stopped from another thread
                      09:52:01: C:/Users/rodriguez/Desktop/pixy2-master/src/host/build-pixymon-Desktop_Qt_5_2_1_MinGW_32bit-Debug/debug/PixyMon exited with code 3

                      The Q_ASSERT(false); did work. In fact, it worked instantly. It closes the program as soon as the program opens and loads without me pressing anything.

                      Honestly, I did not think that such a simple thing as printing a value to the UI would be so difficult. I'm baffled. Is there any way around this that you can think of. I tried to make a global variable to carry the data of m_palette[0] to the Mainwindow.cpp but obviously even that is drawing an error…

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #30

                      @jrod2much said in Signals and slots or whatever:

                      I am 99% sure that Qt Creator does not have a stack trace.

                      The one in the red rectangle is the stack trace
                      0_1538124038320_Capture.PNG

                      @jrod2much said in Signals and slots or whatever:

                      I did not think that such a simple thing as printing a value to the UI would be so difficult.

                      It is not. Sorry to be brutal but it's your inexperience with the language and the tools that is making this difficult. The good news is that once you do it once and you understand it, the next time it will be a breeze

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      J 1 Reply Last reply
                      4
                      • VRoninV VRonin

                        @jrod2much said in Signals and slots or whatever:

                        I am 99% sure that Qt Creator does not have a stack trace.

                        The one in the red rectangle is the stack trace
                        0_1538124038320_Capture.PNG

                        @jrod2much said in Signals and slots or whatever:

                        I did not think that such a simple thing as printing a value to the UI would be so difficult.

                        It is not. Sorry to be brutal but it's your inexperience with the language and the tools that is making this difficult. The good news is that once you do it once and you understand it, the next time it will be a breeze

                        J Offline
                        J Offline
                        jrod2much
                        wrote on last edited by jrod2much
                        #31

                        @VRonin I hope so haha

                        Okay so take a look, nothing is writing to the stack trace but I did notice that for the breakpoints we have different icons.

                        0_1538124554988_130b2d24-b263-4289-93aa-3cdc02a08f44-image.png

                        1 Reply Last reply
                        0
                        • VRoninV Offline
                          VRoninV Offline
                          VRonin
                          wrote on last edited by
                          #32

                          Did you start the debugger? it's the play button with a bug on it. Just above the hammer in the bottom left corner

                          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                          ~Napoleon Bonaparte

                          On a crusade to banish setIndexWidget() from the holy land of Qt

                          J 1 Reply Last reply
                          1
                          • VRoninV VRonin

                            Did you start the debugger? it's the play button with a bug on it. Just above the hammer in the bottom left corner

                            J Offline
                            J Offline
                            jrod2much
                            wrote on last edited by jrod2much
                            #33

                            @VRonin Still nothing and I got this warning

                            0_1538125162731_7c6b217c-a778-4921-8074-7f46ba78314e-image.png

                            Would this warning effect the stack trace? I can take a moment to try and fix it if so. It says that the breakpoints are failing because of it.

                            1 Reply Last reply
                            0
                            • VRoninV Offline
                              VRoninV Offline
                              VRonin
                              wrote on last edited by
                              #34

                              Tools->options->Kits->select the kit that you are using

                              Can you take a screenshot of the page?

                              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                              ~Napoleon Bonaparte

                              On a crusade to banish setIndexWidget() from the holy land of Qt

                              J 1 Reply Last reply
                              0
                              • VRoninV VRonin

                                Tools->options->Kits->select the kit that you are using

                                Can you take a screenshot of the page?

                                J Offline
                                J Offline
                                jrod2much
                                wrote on last edited by jrod2much
                                #35

                                @VRonin
                                0_1538125910939_c9fdcb63-f48e-4c91-9c6e-ce928e37541e-image.png

                                Yeah, as you can imagine, the process of getting the project to build was a nightmare for me as a person with no experience so i probably did something wrong. Hence the yellow warnings.

                                1 Reply Last reply
                                0
                                • VRoninV Offline
                                  VRoninV Offline
                                  VRonin
                                  wrote on last edited by
                                  #36

                                  The fact that it says "no compiler" and you are compiling makes me think you didn't select the correct kit. If I had to bet I'd say you are using the MinGW kit.

                                  P.S.
                                  Qt 5.2 has not been supported for a long while. Any reason why you are not updating?

                                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                  ~Napoleon Bonaparte

                                  On a crusade to banish setIndexWidget() from the holy land of Qt

                                  J 1 Reply Last reply
                                  1
                                  • VRoninV VRonin

                                    The fact that it says "no compiler" and you are compiling makes me think you didn't select the correct kit. If I had to bet I'd say you are using the MinGW kit.

                                    P.S.
                                    Qt 5.2 has not been supported for a long while. Any reason why you are not updating?

                                    J Offline
                                    J Offline
                                    jrod2much
                                    wrote on last edited by
                                    #37

                                    @VRonin :( On the pixyMon website, the forum people said that 5.2 is the only one that works, I could try other versions but it would take me hours. I don't mind doing that though if you think it would be lucrative.

                                    VRoninV JKSHJ 2 Replies Last reply
                                    0
                                    • J jrod2much

                                      @VRonin :( On the pixyMon website, the forum people said that 5.2 is the only one that works, I could try other versions but it would take me hours. I don't mind doing that though if you think it would be lucrative.

                                      VRoninV Offline
                                      VRoninV Offline
                                      VRonin
                                      wrote on last edited by
                                      #38

                                      @jrod2much said in Signals and slots or whatever:

                                      5.2 is the only one that works

                                      Nevermind then, focus on the main point i.e. the screenshot of the kit you are actually using

                                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                      ~Napoleon Bonaparte

                                      On a crusade to banish setIndexWidget() from the holy land of Qt

                                      1 Reply Last reply
                                      0
                                      • J jrod2much

                                        @VRonin :( On the pixyMon website, the forum people said that 5.2 is the only one that works, I could try other versions but it would take me hours. I don't mind doing that though if you think it would be lucrative.

                                        JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on last edited by
                                        #39

                                        @jrod2much said in Signals and slots or whatever:

                                        @VRonin :( On the pixyMon website, the forum people said that 5.2 is the only one that works, I could try other versions but it would take me hours. I don't mind doing that though if you think it would be lucrative.

                                        If the authors found that Qt 5.2 is most stable, then it's best to stick to Qt 5.2.

                                        An important point from http://cmucam.org/projects/cmucam5/wiki/Building_PixyMon : The authors used the MinGW compiler, not the MSVC compiler. So, close Qt Creator, launch MaintenanceTool.exe (found in the root folder of your Qt installation) and:

                                        • Remove (Uninstall) all the MSVC-based versions of Qt.
                                        • Add (Install) Tools > MinGW 4.8 (this is the version of MinGW that goes with Qt 5.2)

                                        Some questions for sanity checks:

                                        1. How did you install Qt in the first place?
                                        2. How/Why did you create the "Desktop" and "Qt Version 1" kits?

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

                                        1 Reply Last reply
                                        3
                                        • J Offline
                                          J Offline
                                          jrod2much
                                          wrote on last edited by jrod2much
                                          #40

                                          @VRonin Here is a picture of the correct kit. The breakpoints are still not working. @JKSH This picture was taken after I followed the steps you gave me.
                                          0_1538380476205_ea478f89-ecc7-42c0-b82c-159ab3fd4d61-image.png

                                          I downloaded Qt using the Qt installer, but when I first tried to build the project, the default installation "Tools" was not enough at first so I experimented by downloading many different versions. As for the "Desktop" and "Qt version" kits, if I could tell you how I did it or even why, I wouldn't be on this forum with the type of questions I've been asking Lmao.

                                          Here is the caution error message attached to the kit if it is helpful:

                                          0_1538380936038_16febb11-1878-4612-b1f6-42b179591112-image.png

                                          JKSHJ 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