Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QGridLayout span problems



  • Hey,
    I've got a problem with spanned items in grid layout.

    I want to have a layout as seen on this picture:

    441dfc8e-ed70-4c92-9b28-c81bc8b195c1-image.png

    "Aaaa..." - QLabel, addWidget(..., 0, 0, 1, 5), QSizePolicy::Preferred
    Line edit - QLineEdit, addWidget(..., 0, 5, 1, 1), QSizePolicy::Preferred
    "Bbb" - QLabel, addWidget(..., 1, 0, 1, 1), QSizePolicy::Preferred
    Line edit (short) - QLineEdit, addWidget(..., 1, 1, 1, 1), QSizePolicy::Fixed
    Line edit (long) - QLineEdit, addWidget(..., 1, 3, 1, 2), QSizePolicy::Ignored

    But what I get is this:

    cb5817f1-5714-4bf0-aefa-d3e577388fe2-image.png

    As one can see the "Aaaa..." label space is divided equally between the cell 0...4 (see the second row). But what I need is to divide "spanned" space non-lineary between widgets base on size of the widget.

    Could this be somehow done with QGridLayout or do I need to implement my own layout manager?

    Thank you


Log in to reply