Results 1 to 7 of 7

Thread: exclusive checkBox

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Question exclusive checkBox

    Hi, in designer I put in a buttonGroup 3 checkButton and make it exclusive. When application starts, nothing button is checked (ok). When I check one they then I change and exclusive works; but I'd like to de-select all checkbox: with exclusive this is impossible. Is there a simple way to obtain this?
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: exclusive checkBox

    what happens if you add a button "clear all" to your dialog and connect its clicked() signal to a slot in which you call chkBUtton->setChecked ( false ) to all the check buttons in the button group?

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: exclusive checkBox

    I didn't try! But I need de-selected in the same way of selecting....Is it possible Qt not think to this?
    Regards

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

  5. #5
    Join Date
    Oct 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: exclusive checkBox

    Hello people

    I have one problem, i want to create dynamicly one group of checkboxes witch data i have to read from one SQL table.

    The code :

    QButtonGroup *AnsDialog::createExclusiveGroup()
    {
    int i = 0;

    QSqlQuery query;


    //QStringList names;

    QGroupBox *groupBox = new QGroupBox(" Awnsers ");

    QString s = "SELECT id, text FROM answer WHERE language =\"pt\"";
    query.exec(s);

    while ( query.next()) {
    QString ansTemp =query.value(1).toString();
    QCheckBox *q = new QCheckBox(ansTemp, groupBox);

    mas.append(*q);

    idAnswers.append(query.value(0).toString());

    CheckBox=new QCheckBox(Checkbox.sprintf(ansTemp,i),groupBox);

    }


    return groupBox;

    }

    I can´t compile it, is say's :

    ".\AnsDialog.cpp(86) : error C2228: left of '.append' must have class/struct/union"

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: exclusive checkBox

    I can´t compile it, is say's :

    ".\AnsDialog.cpp(86) : error C2228: left of '.append' must have class/struct/union"
    'mas' and 'idAnswers' are not defined in this function.
    I don't know on which one the compiler complains about since you didn't state which line is line 86.
    Make sure both above variables are defined.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: exclusive checkBox

    It could be a missing include directive. Where and how are mas and idAnswers declared? Did you include corresponding headers?
    J-P Nurmi

Similar Threads

  1. boolean field checkbox QTableView
    By skuda in forum Qt Programming
    Replies: 4
    Last Post: 8th November 2010, 13:48
  2. A few queries about Model View Programming
    By montylee in forum Qt Programming
    Replies: 46
    Last Post: 2nd March 2009, 08:36
  3. QTreeView: How to center a checkbox in a cell
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 19th December 2008, 12:11
  4. Need some help re-painting a checkbox
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 16:08
  5. checkbox
    By nErnie in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2006, 21:59

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.