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. Setting the geometry of a form after setting the layout
Forum Updated to NodeBB v4.3 + New Features

Setting the geometry of a form after setting the layout

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 621 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dolevo
    wrote on last edited by
    #1

    Hi all,

    I have a form in which I create the radiobuttons at runtime.
    What I do is:

    @ lay->setVerticalSpacing(1);
    lay->setHorizontalSpacing(1);
    lay->setSizeConstraint(QLayout::SetMaximumSize);

    setLayout(lay);
    
    ...
    
    foreach(QString str_cap, cap)
    {
        QRadioButton *button1 = new QRadioButton();
        button1->setText(QString("%1").arg(str_cap));
        lay->addWidget(button1, localcount, int(localcount/10));
        group->addButton(button1, count);
        count++;
        localcount++;
    }
    

    @

    This works perfect to show the first set of radiobuttons. Whenever user clicks on a radiobutton, I make existing radiobuttons hidden using the following code:

    @ foreach(QAbstractButton *but, group->buttons())
    but->hide();
    @

    This code works also good, I see the the all existing radiobuttons become hidden. However, I use the same function to recreate a second bunch of radiobuttons. What happens is that, my code hides the first group and shows the new bunch but the form size comes as zero. So, after clicking on a radiobutton in the first group, the second group is shown but I can only see it after resizing the form window with mouse. So, how can I adjust the size of the layout after adding-removing some radiobuttons?

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

      Hi,

      You shouldn't need to but you can try to call adjustSize

      Hope it helps

      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

      • Login

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