
Originally Posted by
Yayati.Ekbote
Hi!!
I am having a serious problem with QT designing. When i draw widgets on the form in say xyz.ui file. these widgets don't get connected to the code i write in xyz.h file and xyz.cpp file.
The widgets which are drawn on the form have no use. When in implementation file i initialise QPushButton *button = new QPushButton(tr("New"));
a new button appears on the form with the old button drawns on the xyz.ui file in the back. Why does this happen? Do i have to link the individual button interface to its code in implementation file explicitly? If yes then how? if no then what to do??
Plz guide!!
If you are loading the ui file and using it as a widget try the following:
QPushButton *button
= qFindChild<QPushButton
*>
(QUiLoader::load("xyz.ui"),
"name_of_your_button_in_your_ui_file");
QPushButton *button = qFindChild<QPushButton *>(QUiLoader::load("xyz.ui"), "name_of_your_button_in_your_ui_file");
To copy to clipboard, switch view to plain text mode
Edit: Of course the return widget from QUiLoader is going to be needed elsewhere and should be saved and only referenced instead of single called and thrown away in the example.
Bob
Bookmarks