The Qt program runs but the popup window doesn't display anything
Unsolved
Installation and Deployment
-
This is the Header file
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QWidget> #include <QSpinBox> #include <QSlider> #include <QDial> #include <QProgressBar> class MainWindow : public QMainWindow { Q_OBJECT private: QSpinBox *spinbox; QSlider *slider1; QDial *dial; QProgressBar *progressbar; public: MainWindow(); / /~MainWindow(); }; #endif // MAINWINDOW_H
This is the MainWindow file
#include "mainwindow.h" #include <QVBoxLayout> #include <QGridLayout> MainWindow::MainWindow() { spinbox = new QSpinBox; slider1 = new QSlider(Qt::Horizontal); dial = new QDial; progressbar = new QProgressBar; QVBoxLayout *lay1 = new QVBoxLayout(this); //QGridLayout *lay1 = new QGridLayout(this); lay1 -> addWidget(spinbox); lay1 -> addWidget(slider1); lay1 -> addWidget(dial); lay1 -> addWidget(progressbar); setLayout(lay1); }
This is the Main file
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
-
Hi and welcome to devnet,
QMainWindow already has a layout.
What you can do is create a QWidget where you apply your layout and set it as central widget.