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. 3 State QPushbutton (solved)
Forum Updated to NodeBB v4.3 + New Features

3 State QPushbutton (solved)

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 4.2k Views 2 Watching
  • 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by houmingc
    #1

    I understood Qt Qpushbutton have 2 state: click and unclick. Is it possible to have additional state in QPushbutton?

    How to achieve the third state?

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

      Hi,

      Do you mean something like QCheckBox's tristate property ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean something like QCheckBox's tristate property ?

        H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        How can this apply to qpushbutton?

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

          You would need to create your own button from QAbstractButton and take some inspiration from QCheckBox. But first, why do you need a tristate push button ? It's not something that follows known guidelines

          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
          • H Offline
            H Offline
            houmingc
            wrote on last edited by
            #5

            Many thanks for your expertise

            1 Reply Last reply
            0
            • H houmingc

              I understood Qt Qpushbutton have 2 state: click and unclick. Is it possible to have additional state in QPushbutton?

              How to achieve the third state?

              J Offline
              J Offline
              Jakob
              wrote on last edited by
              #6

              @houmingc Even easier would be to make use of the nextCheckState() function. It allows you to create any number of states, see http://doc.qt.io/qt-5/qabstractbutton.html#nextCheckState

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

                @Jakob that's what is used for QCheckBox internally, it's a good example on how to use nextCheckState

                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