could you prepare compilable example and show it?
could you prepare compilable example and show it?
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
I attach a folder with 3 files, the parent header from QtDesigner and the child.
The parent class is Ui_Form and the child class is paintimagewidget. I changed the names of the files. The original for the parent was ui_manysift.h and for the child paintimagewidget
there are two ways to set up ui
1.
2.Qt Code:
//h-file #include "ui_manysift.h" { Q_OBJECT .... }; //cpp-file { setupUi(this); }To copy to clipboard, switch view to plain text mode
PS. this is not compilable example, I can't do qmake && nmake.Qt Code:
//h-file #include "ui_manysift.h" { Q_OBJECT .... private: Ui::Form m_ui; }; //cpp-file { m_ui.setupUi(this); }To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
I had a mistake in forward declaration. I found it, so now it works. Thanx for the help anyway ...
if modify second approch you can get more perfomance on compilation stage, i.e. if ui-file has been modified then only needed cpp file will be rebuild. this approach is very usefull in big project with many ui-files.
Qt Code:
//h-file #include <QWidget> namespace Ui { class MyWidget; }; { Q_OBJECT public: virtual ~MyWidget(); private: Ui::MyWidget *m_ui; }; //cpp-file #include "mywidget.h" #include "ui_mywidget.h" { m_ui = new Ui::MyWidget; m_ui->setupUi(this); } MyWidget::~MyWidget() { delete m_ui; m_ui = 0; }To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
So, in general there is no real advantage in any of the two first approaches, except that it's probably easiser to modify the second one to the third that you posted?
The third approach looks very interesting, I guess it can save quite some compile time while developing an application.
Yesthe third one is usefull when you have a lot of ui files
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
I see thatI always wondered what the difference between the first two ones was, but it just seems to be a matter of taste
Thanks for clarifying that, and for pointing out the third one. I have to keep that one in mind, it might come in handy some day
![]()
Bookmarks