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. [SOLVED]Update GUI from a no-QThread
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Update GUI from a no-QThread

Scheduled Pinned Locked Moved General and Desktop
14 Posts 7 Posters 11.6k 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.
  • M Offline
    M Offline
    MuldeR
    wrote on last edited by
    #4

    Your class needs to inherit from QObject to be able to emit signals, yes.

    But it doesn't have to be a QThread. Just inheriting from QObject should be sufficient, I think.

    As you didn't say what errors you got, it's hard to say what was wrong...

    Note, however, that you'll have to include Q_OBJECT in your class definition and use the MOC!

    Please see:
    http://doc.qt.digia.com/qt/moc.html

    My OpenSource software at: http://muldersoft.com/

    Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

    Go visit the coop: http://youtu.be/Jay...

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TFabbri
      wrote on last edited by
      #5

      I try what you say, but I obtained these errors:
      @
      build/Debug/GNU-Linux-x86/main.o: In function TestTime': .../QtApplicationMoc/main.cpp:16: undefined reference to vtable for TestTime'
      .../QtApplicationMoc/main.cpp:16: undefined reference to vtable for TestTime' build/Debug/GNU-Linux-x86/main.o: In function ~TestTime':
      .../QtApplicationMoc/main.cpp:19: undefined reference to vtable for TestTime' .../QtApplicationMoc/main.cpp:19: undefined reference to vtable for TestTime'
      @

      I'll try to be more clear; my class is structured as follows:
      @
      class TestTime : public myClassThread , public QObject{
      Q_OBJECT
      public:
      TestTime(QObject * parent = 0){}
      ~TestTime(){}
      public:
      void onDataReceived(...){...}
      void onStartUp(){...}
      void iterate(){...}
      signals:
      void mySignal();
      public slots:
      void mySlot();
      };
      @
      To be sure, I've runed the qmake command but I've the same errors.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guziemic
        wrote on last edited by
        #6

        Did you add header file information to .pro file?

        @
        HEADERS += TestTime.h
        @

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KA51O
          wrote on last edited by
          #7

          I think you need to "put QObject first":http://doc.qt.digia.com/4.7/moc.html#multiple-inheritance-requires-qobject-to-be-first in your class declaration, for moc to work properly.

          Thus, you need to change:
          @
          class TestTime : public myClassThread , public QObject
          @
          to this:
          @
          class TestTime : public QObject, public myClassThread
          @

          1 Reply Last reply
          0
          • U Offline
            U Offline
            utcenter
            wrote on last edited by
            #8

            Always put QObject at the bottom of the inheritance hierarchy, i.e. first

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #9

              Probably better to just not multi-inherit from anything besides a pure interface.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TFabbri
                wrote on last edited by
                #10

                Thank you to all! I've solved my first problem, but I've a new one.
                I use many libraries in my project, and some of them has the definition of the function in the file .h, for example:

                @
                file library.h

                namespace A{
                namespace B{
                bool funcion1(...){...}
                bool function2(...){...}
                }
                namespace C{
                ...
                }
                }
                @

                If I include this file in my project, I've many problems as follows:

                @
                build/Debug/GNU-Linux-x86/CommandControlApp.o: In function sign': /.../QtGuiC2/../ECL/includes/ecl_utils.h:29: multiple definition of MS_topics'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:29: first defined here
                build/Debug/GNU-Linux-x86/CommandControlApp.o: In function sign': /.../QtGuiC2/../ECL/includes/ecl_utils.h:30: multiple definition of SSS_topics'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:30: first defined here
                build/Debug/GNU-Linux-x86/CommandControlApp.o: In function intToString': /.../QtGuiC2/../ECL/includes/ecl_utils.h:46: multiple definition of messageType'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:46: first defined here
                build/Debug/GNU-Linux-x86/moc_CommandControlApp.o: In function sign': /.../QtGuiC2/../ECL/includes/ecl_utils.h:29: multiple definition of MS_topics'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:29: first defined here
                build/Debug/GNU-Linux-x86/moc_CommandControlApp.o: In function sign': /.../QtGuiC2/../ECL/includes/ecl_utils.h:30: multiple definition of SSS_topics'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:30: first defined here
                build/Debug/GNU-Linux-x86/moc_CommandControlApp.o: In function intToString': /../QtGuiC2/../ECL/includes/ecl_utils.h:46: multiple definition of messageType'
                build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:46: first defined here
                collect2: ld returned 1 exit status
                @

                How can I solve it?
                How can I disable the -Wall option during the compile process?
                By searching in the web I find that the problem can be due by the moc... any suggestions?
                Thank you to all!

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MuldeR
                  wrote on last edited by
                  #11

                  @/.../QtGuiC2/../ECL/includes/ecl_utils.h:30: multiple definition of `SSS_topics'
                  build/Debug/GNU-Linux-x86/main.o:/.../QtGuiC2/../ECL/includes/ecl_utils.h:30: first defined here@

                  Defined again at "ecl_utils.h", line 30. First definition in the very same file, at the very same line ;-)

                  Looks like the same .h file is included multiple times, thus the warning about multiple definitions!

                  This can easily happen if you include A.h and B.h in your source code file, but the file B.h also includes A.h. Or file B.h includes some other header file that then includes A.h (again). There are many ways this mess can happen.

                  Usually this problem is avoided/resolved by guarding all header files like this:
                  @foobar.h

                  #ifndef FOOBAR_H_INCLUDED
                  #define FOOBAR_H_INCLUDED

                  /* Actual declarations here */

                  #endif //FOOBAR_H_INCLUDED@

                  So if it will be included a second (or third (or fourth)) time, it won't do any harm :)

                  If the .h files of the libraries you are using have not been "guarded" like that, you have to fix that yourself (or ask the library author to fix it). Either that or you have to carefully check "who includes whom" and try to avoid multiple includes of the same .h file by re-organizing your #include commands...

                  My OpenSource software at: http://muldersoft.com/

                  Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                  Go visit the coop: http://youtu.be/Jay...

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    TFabbri
                    wrote on last edited by
                    #12

                    My libraries have already the #ifndef ... #endif.
                    This error for example:

                    @
                    /home/tommaso/Code/QtGuiC2/../ECL/includes/ecl_utils.h:30: multiple definition of `SSS_topics'
                    build/Debug/GNU-Linux-x86/main.o:/home/tommaso/Code/QtGuiC2/../ECL/includes/ecl_utils.h:30: first defined here
                    @

                    It indicates that at line 30 SSS_topics is defined, but there isn't any definition of this variable...

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      TFabbri
                      wrote on last edited by
                      #13

                      I've solved my problem by splitting the definitions of a .h file to .cpp + .h files.
                      The main problem was that I've a declaration of a map into a .h file (SSS_topics and the others).
                      Since I moved the definition into the .cpp file, my problems seems to be over.
                      Thank you!

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Macro
                        wrote on last edited by
                        #14

                        Thanks all for your replies...!!!

                        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