Cat
19th October 2015, 11:59
Hello. I recently started to work with Qt and Qwt. I can't find my mistake by myself. Please help me. There is the code:
I know that my mistakes in somewhere here:
.h file
...
class MainWindow : public
QMainWindow
{
Q_OBJECT
QWidget *centralWidget;
public:
MainWindow(QWidget *parent = 0);
...
.cpp
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent) {
...
...
void MainWindow::setPlotButton() {
button = new QPushButton("push"),
button->setCheckable(true);
connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
QHBoxLayout *plotsLayout = new QHBoxLayout;
plotsLayout->setSpacing(10);
plotsLayout->addWidget(funPlot);
QHBoxLayout *buttonsLayout = new QHBoxLayout ;
buttonsLayout->addWidget(button);
QVBoxLayout *widgetLayout = new QVBoxLayout;
widgetLayout->addLayout(plotsLayout);
widgetLayout->addLayout(buttonsLayout);
setLayout(widgetLayout);
...
}
I recieve a message "QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout". What I should change?
I know that my mistakes in somewhere here:
.h file
...
class MainWindow : public
QMainWindow
{
Q_OBJECT
QWidget *centralWidget;
public:
MainWindow(QWidget *parent = 0);
...
.cpp
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent) {
...
...
void MainWindow::setPlotButton() {
button = new QPushButton("push"),
button->setCheckable(true);
connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
QHBoxLayout *plotsLayout = new QHBoxLayout;
plotsLayout->setSpacing(10);
plotsLayout->addWidget(funPlot);
QHBoxLayout *buttonsLayout = new QHBoxLayout ;
buttonsLayout->addWidget(button);
QVBoxLayout *widgetLayout = new QVBoxLayout;
widgetLayout->addLayout(plotsLayout);
widgetLayout->addLayout(buttonsLayout);
setLayout(widgetLayout);
...
}
I recieve a message "QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout". What I should change?