How to arrange the items in QGridLayout as shown?

后端 未结 2 1402
青春惊慌失措
青春惊慌失措 2021-02-12 14:43
------------  ------
|          |  | 2  |
|          |  |    |
|     1    |  ------
|          |  ------  
|          |  |  3 |
------------  ------

Ho

2条回答
  •  盖世英雄少女心
    2021-02-12 14:51

    Check the addWidget documentation. You can provide the rowSpan and columnSpan

    QGridLayout *layout = new QGridLayout();
    centralWidget->setLayout (layout);
    
    layout->addWidget (objOne, 0, 0, -1, 1);
    layout->addWidget (objTwo, 0, 1, 1, 1);
    layout->addWidget (objThree, 1, 1, 1, 1);
    

    Notice however that it is much easier to create the desired layout using QtDesigner. Check this Qt documentation page for more details

提交回复
热议问题