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. Convert a QPushButton into another QPushButton
Forum Updated to NodeBB v4.3 + New Features

Convert a QPushButton into another QPushButton

Scheduled Pinned Locked Moved General and Desktop
qpushbutton
3 Posts 3 Posters 1.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.
  • JorgeJ Offline
    JorgeJ Offline
    Jorge
    wrote on last edited by
    #1

    Hi,
    Is there any way to convert a QPushButton to another QPushButton?
    What I mean is, if for example I had a Start button, I would like for it to change to a Stop button when it is pressed.
    I know I could use two buttons, but I'm trying to achieve a clean User Interface and a minimalistic design without the clutter of buttons that are not enabled if another one is pressed.

    Thanks in advance.

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can create two buttons and hide one of them (instead of just disabling it) using hide()/show() or setVisible().

      You can also change the text with setText().

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HeavyMetalMike
        wrote on last edited by
        #3

        You can change the text or icon (setIcon()) as Chris mentioned. If you want to change the behavior you can have an if clause in the on_clicked() method. If you also want to change the color of the button you can use setStyleSheet().

        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