Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. The Qt program runs but the popup window doesn't display anything

The Qt program runs but the popup window doesn't display anything

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 159 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lldn8991
    wrote on last edited by
    #1

    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();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved