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. Solved:Qt:How to make the checkbox‘s “isChecked()” state return back unchecked state with code?

Solved:Qt:How to make the checkbox‘s “isChecked()” state return back unchecked state with code?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.3k 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.
  • A Offline
    A Offline
    Adam_wang
    wrote on 7 Jul 2014, 08:38 last edited by
    #1

    I want to remove the tick of checkbox which is selected by the the user with code to implement some functions.Such the user can select the checkbox again.How I can do it using code?

    the code statements look like the followed :

    if(ui-> checkBox_HB->isChecked())
    {
    Here I want make the checkBox_HB return back unckecked state(remove the tick)
    }

    1 Reply Last reply
    0
    • P Offline
      P Offline
      poorBob
      wrote on 7 Jul 2014, 09:07 last edited by
      #2

      Hmmm,

      maybe try to connect to the signal: "toggled":http://qt-project.org/doc/qt-4.8/qabstractbutton.html#toggled or "stateChanged":http://qt-project.org/doc/qt-4.8/qcheckbox.html#stateChanged to figure out when the checkbox was toggled?

      Then You can use the "setCheckState":http://qt-project.org/doc/qt-4.8/qcheckbox.html#setCheckState with Qt::Unchecked value( "CheckState enum":http://qt-project.org/doc/qt-4.8/qt.html#CheckState-enum )

      hope this will help You,

      poorBob

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheBadger
        wrote on 7 Jul 2014, 10:41 last edited by
        #3

        You can also do QCheckBox::setChecked(bool checked) function (from QAbstractButton) if you do not care about the other checked states apart from checked and unchecked


        Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Adam_wang
          wrote on 8 Jul 2014, 06:07 last edited by
          #4

          [quote author="Badger" date="1404729699"]You can also do QCheckBox::setChecked(bool checked) function (from QAbstractButton) if you do not care about the other checked states apart from checked and unchecked[/quote]

          OK,it works well,and thank you very much ! I'm a freshman to study Qt by myself.I indeed have to read more materials about Qt assistance, maybe I can solve the problem by myself.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adam_wang
            wrote on 8 Jul 2014, 06:11 last edited by
            #5

            Thanks a lot. I’m a freshman to study Qt by myself.I indeed have to read more materials about Qt assistance, maybe I can solve the problem by myself. Thank you once more!
            [quote author="poorBob" date="1404724025"]Hmmm,

            maybe try to connect to the signal: "toggled":http://qt-project.org/doc/qt-4.8/qabstractbutton.html#toggled or "stateChanged":http://qt-project.org/doc/qt-4.8/qcheckbox.html#stateChanged to figure out when the checkbox was toggled?

            Then You can use the "setCheckState":http://qt-project.org/doc/qt-4.8/qcheckbox.html#setCheckState with Qt::Unchecked value( "CheckState enum":http://qt-project.org/doc/qt-4.8/qt.html#CheckState-enum )

            hope this will help You,

            poorBob[/quote]

            1 Reply Last reply
            0

            1/5

            7 Jul 2014, 08:38

            • Login

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