PDA

View Full Version : QMainWindow access children of centralWidget



sfabel
12th October 2010, 02:14
Hi all,

stupid question. I use QDesigner, drew a QMainWindow with a QWidget centralWidget. Inside, there's a layout and a couple of children (buttons, tables, etc.).

All the classes are autogenerated using QtCreator.

My TMainWindow class looks like this:


TMainWindow::TMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TMainWindow)
{
ui->setupUi(this);
}


Now I want to connect one of the pushButtons to qApp() / quit. But every time I type in ui->..., I can't access the pushButtons.

When I open the designer form in QDesigner, the hierarchy is this:

TMainWindow
\-> centralWidget (QWidget)
____\-> gridLayout (QGridLayout)
________\-> btn_Quit (QPushButton)

However the centralWidget has this "forbidden" icon on the lower right corner. Does this have something to do with it and how do I access the children of centralWidget?

Thanks,
Stephan

tbscope
12th October 2010, 04:39
ui->btn_Quit should work.