Results 1 to 4 of 4

Thread: Can't get isChecked() properties but get everything else from dock

  1. #1
    Join Date
    Sep 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't get isChecked() properties but get everything else from dock

    All the following code produces the same result: I query the radio/checkbox buttons on a simple dock and can successfully get all the correct information from the buttons except for the currently checked state. What is returned is always the default checked state as set in ui->, not the checked state as it appears on screen after checking it. I'm providing the code and the output. Is there anything in the rest of the extensive program, such as an event filter or something that is too big or I can't think of to post, that could interfere with this?

    Qt Code:
    1. QAbstractButton* qb = ui->accBtnGrp->checkedButton();
    2. qDebug()<< qb << "Checked Btn:"<< qb;
    3.  
    4. QList<QAbstractButton*>btns = ui->accBtnGrp->buttons();
    5.  
    6. foreach(QAbstractButton* b, btns ) {
    7. qDebug()<< b << "Checkable:"<< b->isCheckable();
    8. qDebug()<< b << "Checked:"<< b->isChecked();
    9.  
    10. }
    11.  
    12. bool cb = ui->ckbx_DottedNote->isChecked();
    13. qDebug()<< ui->ckbx_DottedNote << "Checkable:"<< ui->ckbx_DottedNote->isCheckable();
    14. qDebug()<< ui->ckbx_DottedNote << "Checked:"<< ui->ckbx_DottedNote->isChecked();
    To copy to clipboard, switch view to plain text mode 

    In the results below, the "Normal" rbtn shows "Checked" but on screen it is actually the sharp button that was clicked and is now the checked button.The checkbox is also checked but since it is not checked by default it polls as false. All buttons (except the checkbox which is separate) are autoexclusive and are in the same buttongroup.
    Qt Code:
    1. QRadioButton(0x3b61a78, name = "rbtn_Normal") Checked Btn: QRadioButton(0x3b61a78, name = "rbtn_Normal")
    2. QRadioButton(0x3b61a78, name = "rbtn_Normal") Checkable: true
    3. QRadioButton(0x3b61a78, name = "rbtn_Normal") Checked: true
    4. QRadioButton(0x3b61a58, name = "rbtn_Sharp") Checkable: true
    5. QRadioButton(0x3b61a58, name = "rbtn_Sharp") Checked: false
    6. QRadioButton(0x3b61a98, name = "rbtn_Natural") Checkable: true
    7. QRadioButton(0x3b61a98, name = "rbtn_Natural") Checked: false
    8. QRadioButton(0x3b61af8, name = "rbtn_Flat") Checkable: true
    9. QRadioButton(0x3b61af8, name = "rbtn_Flat") Checked: false
    10. QCheckBox(0x3b61b18, name = "ckbx_DottedNote") Checkable: true
    11. QCheckBox(0x3b61b18, name = "ckbx_DottedNote") Checked: false
    To copy to clipboard, switch view to plain text mode 
    Last edited by devdon; 16th December 2011 at 11:04.

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't get isChecked() properties but get everything else from dock

    Try use this:
    Qt Code:
    1. QCheckBox::checkState() & Qt::Checked (Qt::Unchecked and Qt::PartiallyChecked)
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't get isChecked() properties but get everything else from dock

    checkState() returns 0 on the checkbox, which is the same value as returned by isChecked().

  4. #4
    Join Date
    Sep 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't get isChecked() properties but get everything else from dock

    An Update is that if I use setChecked() on the dock buttons, then isChecked() returns the correct information , but the visual buttons are not changed. It is almost as if I am working on phantom buttons behind the scenes and not the ones I see in the dock.


    Added after 17 minutes:


    SOLVED: I was calling the routines on implied "this" when I should have been calling them on the active pointer. Oh well. Thanks anyway.
    Last edited by devdon; 16th December 2011 at 19:49.

Similar Threads

  1. Programmatically Dock
    By venkateshhegde in forum Newbie
    Replies: 4
    Last Post: 14th February 2011, 00:35
  2. What's a 'Dock' and...
    By Patrick Sorcery in forum Newbie
    Replies: 1
    Last Post: 27th August 2010, 05:40
  3. Replies: 1
    Last Post: 3rd May 2010, 17:31
  4. forcing dock windows to dock?
    By eric_vi in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2009, 15:32
  5. QCheckBox::isChecked() property is not working...
    By Cutey in forum Qt Programming
    Replies: 10
    Last Post: 18th August 2008, 08:14

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.