Results 1 to 2 of 2

Thread: Accessing Dynamically created Checkboxe

  1. #1
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Accessing Dynamically created Checkboxe

    I am dynamically creating check-boxes inside a layout & populating it using a sqlquery. I want to get a list of all the check boxes checked by the user. I know that check-boxes have a checked property. but how do I get a list of all the check-boxes created dynamically?

    QCheckBox *checkbox = new QCheckBox(QString(query.value(2).toString()),this) ;
    checkbox->setStyleSheet("font: MS Shell Dlg 2; font-size: 40px; color: white;");
    connect(this->ui->pushButton_2, SIGNAL(clicked()), checkbox, SLOT(deleteLater()));
    this->ui->verticalLayout_2->addWidget(checkbox,0,0);

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Accessing Dynamically created Checkboxe

    use findclildren function
    QList<QCheckedBox *> allCBox = parentWidget.findChildren<QCheckedBox *>();
    the list will have all the created CheckBoxes ...

    then in a loop u can connect all the items in the list ...
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Replies: 6
    Last Post: 20th June 2012, 13:21
  2. Replies: 12
    Last Post: 24th October 2011, 07:56
  3. Two dynamically created object interaction issue
    By kornicameister in forum Qt Quick
    Replies: 2
    Last Post: 9th September 2011, 11:35
  4. Replies: 3
    Last Post: 11th August 2011, 17:16
  5. Dynamically created buttons.
    By Tomasz in forum Newbie
    Replies: 26
    Last Post: 2nd December 2010, 09:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.