[Qt-interest] QMainWindow and QDialog.

Shabd Swarup V shabd at cadence.com
Thu Mar 26 14:07:03 CET 2009


Hi,

 

I have a class called Window which inherits from QMainWindow. Following
is its constructor:

 

Window::Window(QWidget *parent)

: QMainWindow(parent)

{

 

tableWidget = new QTableWidget();

treeWidget = new QTreeWidget();

details = new QTextEdit("Gambler Details");

addButton = createButton(tr("&Add"), SLOT(add()));

editButton = createButton(tr("&Edit"), SLOT(edit()));

graphicsView = new QGraphicsView();

deleteButton = new QPushButton("Delete");

QLabel *filterLabel = new QLabel("Filter Gambler");

 

QHBoxLayout *radioLayout = new QHBoxLayout;

radioLayout->addWidget(filterLabel);

 

QVBoxLayout *buttonsLayout = new QVBoxLayout;

buttonsLayout->addStretch();

buttonsLayout->addWidget(addButton, Qt::AlignVCenter);

buttonsLayout->addWidget(editButton, Qt::AlignVCenter);

buttonsLayout->addWidget(deleteButton, Qt::AlignVCenter);

 

QGridLayout *mainLayout = new QGridLayout;

mainLayout->addWidget(graphicsView, 0, 0, 1, 3);

mainLayout->addWidget(treeWidget, 1, 0,3,1);

mainLayout->addLayout(radioLayout, 1, 1,1,1);

mainLayout->addWidget(tableWidget, 2, 1, 1, 1);

mainLayout->addWidget(details, 3, 1, 1, 2);

mainLayout->addLayout(buttonsLayout, 2, 2, 1, 1);

setLayout(mainLayout);

 

setWindowTitle(tr("Gambler"));

resize(800, 700);

}

 

This displays a completely blank window. Although, if I make Window
inherit from QDialog instead of QMainWindow, the widgets are displayed
perfectly fine. 

 

Please suggest how I can make this work while keeping the base class as
QMainWindow. 

 

Thanks,

Shabd

PS: This is my first Qt GUI app.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090326/6151be0a/attachment.html 


More information about the Qt-interest-old mailing list