Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mainwindow is empty without any widgets.

Mainwindow is empty without any widgets.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.2k 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.
  • H Offline
    H Offline
    houmingc
    wrote on 12 Dec 2014, 00:52 last edited by
    #1

    When i build and run, the mainwindow is empty without any widgets.
    But i have created all the component in the mainwindow constructor.
    why they never appear?
    @
    -----------------MainWindow constructor------------
    ui->setupUi(this);
    brightnessLabel= new QLabel(tr("Brightness :"));
    brightnessName= new QLineEdit;
    brightnessLabel->setBuddy(brightnessName);

    contrastLabel= new QLabel(tr("Brightness :"));
    contrastName= new QLineEdit;
    contrastLabel->setBuddy(contrastName);
    
    volumeLabel= new QLabel(tr("Brightness :"));
    volumeName= new QLineEdit;
    volumeLabel->setBuddy(volumeName);
    
    OutputsourceLabel= new QLabel(tr("Brightness :"));
    OutputsourceName= new QLineEdit;
    OutputsourceLabel->setBuddy(OutputsourceName);
    
    DownloadLabel= new QLabel(tr("Brightness :"));
    DownloadName= new QLineEdit;
    DownloadLabel->setBuddy(DownloadName);
    
    QHBoxLayout *layout =new QHBoxLayout;
    layout->addWidget(brightnessLabel);
    layout->addWidget(brightnessName);
    

    ----------------------main------------------------
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on 12 Dec 2014, 00:55 last edited by
      #2

      You have not assigned the layout to MainWindow.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on 12 Dec 2014, 08:18 last edited by
        #3

        How to assign ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Moschops
          wrote on 12 Dec 2014, 16:26 last edited by
          #4

          QMainWindow inherits a setlayout function.

          http://doc.qt.io/qt-5/qwidget.html#setLayout

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Dec 2014, 22:47 last edited by
            #5

            Hi,

            You can't change the layout of a QMainWindow. What you would do is create a main/container widget 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

            1/5

            12 Dec 2014, 00:52

            • Login

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