12

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.

Community
  • 1
  • 1
Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • 2
    you've already asked this multiple times. setupUi sets up the widgets you describe in the ui file. if you want to know what it does, look at the code generated by `uic`, it's all in there. – Mat Apr 17 '11 at 10:35
  • @Simplicity Thank you for asking this multiple times! – Liviu Mar 28 '17 at 09:41

1 Answers1

22

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);
...
Walker
  • 131
  • 2
  • 16
Barbaris
  • 1,256
  • 7
  • 7