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. Making a layout visible?

Making a layout visible?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 254 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have added a QGridLayout to a window and have several other widgets positioned in it, so far so good.

    I want to add another QGridLayout inside the first QGridLayout. When I add widgets to layout:

    pobjGridLO->addWidget(pobjNode->pobjGetWidget(), intRow, intCol, 1, 1);
    

    Where intRow and intCol are base 0 values. When I create the 2nd layout:

    pobjGridLO->addWidget(pobjSubGridLO->widget(), itRow.i, itCol.i, 1, 1);
    

    pobjGridLO is the first instance of QGridLayout, itRow.i and itCol.i are iterators through rows and columns of widgets to attached to the grid. pobjSubGridLO is a pointer to the 2nd layout that is created, here is the code that creates it:

    pobjSubGridLO = new QGridLayout(pobjGridLO->widget());
    
    if ( pobjSubGridLO != nullptr ) {
        pobjGridLO->addWidget(pobjSubGridLO->widget(), itRow.i, itCol.i, 1, 1);
    

    I can see no evidence that the sub-layout has been added to the first layout, I've added widgets to the 2nd layout but I don't see these either.

    Is there anything I can do to make the layout visible, e.g. give it a red background?

    Can anyone tell me what I may have done wrong?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you want to nest layouts, why don't you use the addLayout method ?

      As for making them visible, no, layouts don't have "physical" appearance. But you can do that for the widgets within the layout.

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

      SPlattenS 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Since you want to nest layouts, why don't you use the addLayout method ?

        As for making them visible, no, layouts don't have "physical" appearance. But you can do that for the widgets within the layout.

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by SPlatten
        #3

        @SGaist thank you, since the widgets aren't visible I asked this question because I wanted some assurance that the layout is actually present where I've added it to be, I will try the addLayout now.

        pobjGridLO->addLayout(pobjSubGridLO, itRow.i, itCol.i, Qt::AlignHCenter);
        

        It works, thank you.

        Kind Regards,
        Sy

        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