Qt - setupUi( ) [duplicate]

2020-08-13 06:16发布

Possible Duplicate:
Qt - initializing the form

I tried to look for a description for the setupUi() method but couldn't find especially in the Qt documentation.

What does this method do? For example, if I write in a class setupUi(this), what will this do? What does setting up a user interface mean at the end?

Thanks.

1条回答
唯我独甜
2楼-- · 2020-08-13 06:52

setupUi() creates the actual instances of widgets for you. A form that you create in QtDesigner is stored just as XML file. So to be able to build the actual "window" with all the elements that you put on it in QtDesigner and display it in your application, setupUi() is created for you automatically by UIC (UI compiler - a Qt tool) so you don't have to do that manually. All the properties that you set in QtDesigner and all elements you put there will be "translated" in C++ code like this:

QLabel *label1 = new QLabel(tr("Start"), this);
QTableView *view1 = new QTableView(this);
...
查看更多
登录 后发表回答