Results 1 to 11 of 11

Thread: add .ui file with custom widget in application

  1. #1
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation add .ui file with custom widget in application

    Hi,

    today I create a self-designed widget, and successfully add it into the designer. I can add it into myDialog.ui in designer.

    But then the problem arises, the ui_myDialog.h can not recognize this new widget.

    PS: I use " ui.setupUi(this);" in the class to add in the ui.

    Who can help me? Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    I guess the initialization of the plugin module has some problem. I check it first.

  3. #3
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    No.... There should be no problem.

    Currently the compiling error is:
    Qt Code:
    1. Error 1 error C2061: syntax error : identifier 'myWidget' d:\cvs\module\GeneratedFiles\ui_myDialog.h 263
    To copy to clipboard, switch view to plain text mode 

    And this piece of code is only the initialization of my self-designed widget:
    Qt Code:
    1. myWidget = new myWidget(DialogClass);
    To copy to clipboard, switch view to plain text mode 

    Help...

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    What do you mean by "can not recognise" ?

  5. #5
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    OK, I found the problem is that I use the same name for both instance and the class name...
    Sorry...

    Now it has link error.
    I am not sure, after adding the widget into the dialog (in designer), the .lib (which is for designer plugin folder) should be added into the project also? I am confused how this widget will work propriately...

  6. #6
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    No body knows???

    You can test like this. You put a widget called "WorldTimeClock" in designer in your own dialog *.ui file. During compiling, there is link error.

    This is the same problem that I encountered. Hope sb can help. Thanks in advance.

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    I don't think it's the "No body knows", but more along the fact of your question is ambiguous.

    "there is link error". There's is about 70,000 different answers to that, which would you like to hear? Or you could post something a bit more specific.

  8. #8
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    Quote Originally Posted by fatjuicymole View Post
    I don't think it's the "No body knows", but more along the fact of your question is ambiguous.

    "there is link error". There's is about 70,000 different answers to that, which would you like to hear? Or you could post something a bit more specific.
    OK, then I post the error messages:
    Qt Code:
    1. Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall WorldTimeClock::WorldTimeClock(class QWidget *)" (__imp_??0WorldTimeClock@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_BodyAdjustmentDialogClass::setupUi(class QDialog *)" (?setupUi@Ui_BodyAdjustmentDialogClass@@QAEXPAVQDialog@@@Z) bodyadjustmentdialog.obj
    2. Error 2 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall WorldTimeClock::metaObject(void)const " (?metaObject@WorldTimeClock@@UBEPBUQMetaObject@@XZ) bodyadjustmentdialog.obj
    3. Error 3 error LNK2001: unresolved external symbol "public: virtual void * __thiscall WorldTimeClock::qt_metacast(char const *)" (?qt_metacast@WorldTimeClock@@UAEPAXPBD@Z) bodyadjustmentdialog.obj
    4. Error 4 error LNK2001: unresolved external symbol "public: virtual int __thiscall WorldTimeClock::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@WorldTimeClock@@UAEHW4Call@QMetaObject@@HPAPAX@Z) bodyadjustmentdialog.obj
    5. Error 5 error LNK2001: unresolved external symbol "protected: virtual void __thiscall WorldTimeClock::paintEvent(class QPaintEvent *)" (?paintEvent@WorldTimeClock@@MAEXPAVQPaintEvent@@@Z) bodyadjustmentdialog.obj
    6. Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall WorldTimeClock::~WorldTimeClock(void)" (__imp_??1WorldTimeClock@@UAE@XZ) referenced in function "public: virtual void * __thiscall WorldTimeClock::`scalar deleting destructor'(unsigned int)" (??_GWorldTimeClock@@UAEPAXI@Z) bodyadjustmentdialog.obj
    7. Error 7 fatal error LNK1120: 6 unresolved externals ..\..\ptf_main\debug\plugins\BodyAdjustmentModule.dl
    To copy to clipboard, switch view to plain text mode 

    What I have done, is add one custom widget called "World Timer Clock" in the designer, into my ui file. Then in one of my class bodyadjustementdialog.cpp, I set the .ui for this class.

    There comes the link error.

    Without the custom widget (world time clock), everything goes fine.

    Hope I make myself clear.

  9. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    Right, so the code for the actual WorldTickClock class is missing, but the class declaration is there. You need to find and add to your project the actual class code that handles the WorldTimeClock class, and then run QMake to update the MOC dependancies, and then it should work.

  10. The following user says thank you to squidge for this useful post:

    stella1016 (19th November 2009)

  11. #10
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    Quote Originally Posted by fatjuicymole View Post
    Right, so the code for the actual WorldTickClock class is missing, but the class declaration is there. You need to find and add to your project the actual class code that handles the WorldTimeClock class, and then run QMake to update the MOC dependancies, and then it should work.
    Thanks for your help. I will have a try right away.

  12. #11
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add .ui file with custom widget in application

    Thanks, it works!!!

Similar Threads

  1. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  2. Replies: 1
    Last Post: 5th November 2006, 23:50
  3. Problem reimplementing QSpinBox in a custom widget
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2006, 08:12
  4. Replies: 4
    Last Post: 24th March 2006, 22:50
  5. Replies: 4
    Last Post: 1st March 2006, 23:11

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.