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. How to get Qwidget that added to Vertical lay out
QtWS25 Last Chance

How to get Qwidget that added to Vertical lay out

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • M Offline
    M Offline
    mehdi.nine
    wrote on last edited by
    #1

    Hi, i add Some Widget to a Vertical lay out. now i want retrieve them like this:

    @
    for(int i =0; i < ui->verticalLayout_6->children().count(); i++)
    {
    QWidget* Widget = dynamic_cast<QWidget*>(ui->verticalLayout_6->children().at(i));
    if(Widget != NULL)
    {
    for(int j = 0; j < Widget->children().count(); j++)
    {
    QLineEdit TempLine = dynamic_cast<QLineEdit>(Widget->children().at(j));
    if(TempLine != NULL)
    {
    TempLine->setText("peida kardam :D :P");
    }
    }

            }
    
    
        }
    

    @
    but ui->verticalLayout_6->children().count(); returns 0. how can i retrieve them?
    any idea?
    another question is that how can change space between Pushbuttons that added to Vertical lay out. I use
    @
    ui->verticalLayout->setSpacing(1);
    @
    but i doesn't work.
    any idea?

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

      Hi,

      Since it looks like you have an UI file... Do you add your widgets programmatically ?

      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