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. Button which will be in pressed state when it's clicked
Qt 6.11 is out! See what's new in the release blog

Button which will be in pressed state when it's clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 3.4k Views 1 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.
  • V Offline
    V Offline
    VladStudent
    wrote on last edited by
    #1

    Hey , everyone. I started learning pyQt and I want a button which will when clicked always in pressed state and when it's going to be clicked again , it's going to be released. I guess it can be achieved with QtWidgets.QPushButton, but which flags to use I don't know. I tried to read all of them , but a lot still looks so hard to grasp. Can anybody help newbie ? Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi and welcome to the forums.
      QPushButton has this feature and its called Checkable/toggle
      http://doc.qt.io/qt-5/qabstractbutton.html#checkable-prop
      its off by default , so you must set setCheckable(true);
      You can use the signal
      http://doc.qt.io/qt-5/qabstractbutton.html#toggled
      to know when pressed/released aka checked / unchecked.

      So you just create the buttons as normal, then
      button.setCheckable(true)
      Then use connect to hook up
      its toggled signal if u want to do stuff when its down / up.

      1 Reply Last reply
      4
      • V Offline
        V Offline
        VladStudent
        wrote on last edited by
        #3

        Awesome, thanks a lot !

        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