PDA

View Full Version : QMainWindow layout questions maybe



lhdgriver
21st July 2010, 18:25
strange error RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

maincode:


#include <QtGui>
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent)
{
QPushButton *previousPushButton = new QPushButton("&Previous");
QPushButton *okPushButton = new QPushButton("&Ok");
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(previousPushButton);
buttonLayout->addWidget(okPushButton);

//
QLabel *nameLabel = new QLabel("&Name");
QLineEdit *nameLineEdit = new QLineEdit;
nameLabel->setBuddy(nameLabel);
QHBoxLayout *nameLayout = new QHBoxLayout;
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameLineEdit);

QLabel *workPlaceLabel = new QLabel("&WorkPlace");
QLineEdit *workPlaceLineEdit[3];
for (int i = 0; i < 3; i++)
workPlaceLineEdit[i] = new QLineEdit;
workPlaceLabel->setBuddy(workPlaceLineEdit[0]);
QGridLayout *workPlaceLayout = new QGridLayout;
workPlaceLayout->addWidget(workPlaceLabel, 0, 0);

for (int i = 0; i < 3; i++)
workPlaceLayout->addWidget(workPlaceLineEdit[i], i, 1);

//
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addLayout(nameLayout);
rightLayout->addLayout(workPlaceLayout);
rightLayout->addLayout(buttonLayout);

QTextBrowser *browser = new QTextBrowser();
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addWidget(browser);

QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);

centralWidget()->setLayout(mainLayout);
}


i don't know why this doesn't work

saa7_go
21st July 2010, 18:52
I don't see you call setCentralWidget(QWidget *) in your MainWindow constructor. You need to look at QMainWindow::centralWidget() (http://doc.trolltech.com/4.6/qmainwindow.html#centralWidget) explanation.