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.
Re: add .ui file with custom widget in application
I guess the initialization of the plugin module has some problem. I check it first.
Re: add .ui file with custom widget in application
No.... There should be no problem.
Currently the compiling error is:
Code:
Error 1 error C2061: syntax error : identifier 'myWidget' d:\cvs\module\GeneratedFiles\ui_myDialog.h 263
And this piece of code is only the initialization of my self-designed widget:
Code:
myWidget = new myWidget(DialogClass);
Help...
Re: add .ui file with custom widget in application
What do you mean by "can not recognise" ?
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...
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.
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.
Re: add .ui file with custom widget in application
Quote:
Originally Posted by
fatjuicymole
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:
Code:
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
Error 2 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall WorldTimeClock::metaObject(void)const " (?metaObject@WorldTimeClock@@UBEPBUQMetaObject@@XZ) bodyadjustmentdialog.obj
Error 3 error LNK2001: unresolved external symbol "public: virtual void * __thiscall WorldTimeClock::qt_metacast(char const *)" (?qt_metacast@WorldTimeClock@@UAEPAXPBD@Z) bodyadjustmentdialog.obj
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.
objError 5 error LNK2001: unresolved external symbol "protected: virtual void __thiscall WorldTimeClock::paintEvent(class QPaintEvent *)" (?paintEvent@WorldTimeClock@@MAEXPAVQPaintEvent@@@Z) bodyadjustmentdialog.obj
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
Error 7 fatal error LNK1120: 6 unresolved externals ..\..\ptf_main\debug\plugins\BodyAdjustmentModule.dl
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.
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.
Re: add .ui file with custom widget in application
Quote:
Originally Posted by
fatjuicymole
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. :)
Re: add .ui file with custom widget in application