Results 1 to 8 of 8

Thread: Failed to compiled QT4 with Q_OBJECT when include header file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Failed to compiled QT4 with Q_OBJECT when include header file

    Possibly the problem is the private inheritance of Ui::myQtAppDLG. Try changing it to public or protected. The Q_OBJECT macro inserts some Qt meta-object source code into the class definition, and maybe this is incompatible with private inheritance of the UI class.

    And take anda_skoa's suggestion for separating UI and processing code into different classes. It is never a good design to mix the two up. Makes for bad spaghetti.

  2. #2
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Failed to compiled QT4 with Q_OBJECT when include header file

    Quote Originally Posted by anda_skoa View Post
    What if you just separate UI and processing into to classes?
    A sensible thing to do in any case and could totally avoid the problem you are seeing.

    Cheers,
    _

    Hi anda_skoa & d_stranz

    I new with QT GUI, I using QT designer to generate a form. Then I use normal editor to write a source file. Original I use a sample code from internet which is running well. Once I add in my code [Not touch on any QT code] then it compiled error.

    I not sure how to separate the UI, can you provide me guideline/example based on my above sample code? I had stuck with this many weeks.. really hope can settle it soon. bcoz backend I still need to do lots low level hardisk drive code.

    I just need a simple GUI with few button, the button will send some hard disk command to retrieve some information. :-)

    Thanks again.

    Quote Originally Posted by d_stranz View Post
    Possibly the problem is the private inheritance of Ui::myQtAppDLG. Try changing it to public or protected. The Q_OBJECT macro inserts some Qt meta-object source code into the class definition, and maybe this is incompatible with private inheritance of the UI class.

    And take anda_skoa's suggestion for separating UI and processing code into different classes. It is never a good design to mix the two up. Makes for bad spaghetti.
    I had try this, unfortunately still same error.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Failed to compiled QT4 with Q_OBJECT when include header file

    Quote Originally Posted by teleplan View Post
    I not sure how to separate the UI, can you provide me guideline/example based on my above sample code?
    You put all the non-UI code into a separate class and let the widget hold an instance of that class as a pointer.
    That way you do not need any of these other includes in the header that has the Q_OBJECT.

    Cheers,
    _

  4. #4
    Join Date
    Aug 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Failed to compiled QT4 with Q_OBJECT when include header file

    Quote Originally Posted by anda_skoa View Post
    You put all the non-UI code into a separate class and let the widget hold an instance of that class as a pointer.
    That way you do not need any of these other includes in the header that has the Q_OBJECT.

    Cheers,
    _
    Hi anda_skoa,

    Yes, it compiled now, I separate the non-UI code into another class.
    Really not understand, why my previous QT3 can compiled without any problem which include non-UI code.

    Anyway thanks for help...

Similar Threads

  1. How to force include a header file
    By rawfool in forum Newbie
    Replies: 25
    Last Post: 13th December 2015, 23:34
  2. Replies: 0
    Last Post: 25th July 2011, 14:47
  3. The header file 'mainwindow.h' doesn't include <QObject>.
    By nhs_0702 in forum Qt Programming
    Replies: 5
    Last Post: 14th May 2010, 17:02
  4. Failed to Launch qt 4.4.0 compiled executable in Debug mode
    By nikhilqt in forum Installation and Deployment
    Replies: 2
    Last Post: 25th July 2008, 13:45
  5. unable to include header file
    By sonia in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 08:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.