Pass window pointer to a Layout manager : Layout « Qt « C++






Pass window pointer to a Layout manager

  
Layout two labels 

#include <QApplication>
#include <QVBoxLayout>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget window;

    QVBoxLayout* mainLayout = new QVBoxLayout(&window);
    QLabel* label1 = new QLabel("One");
    QLabel* label2 = new QLabel("Two");

    mainLayout->addWidget(label1);
    mainLayout->addWidget(label2);

    window.show();

    return a.exec();
}

   
    
  








Related examples in the same category

1.Basic layout
2.Dynamic layout
3.Horizontal BoxLayout
4.Grid Layout
5.Layout two labels
6.Nested layout
7.Window layout