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. How to change the display of the button when pressed?

How to change the display of the button when pressed?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 309 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi.
    How to change the display of the button when pressed?
    Initially set the button style:

     ui->register_Button->setStyleSheet(QString::fromUtf8("background-color: rgb(43, 104, 255); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;"));
    

    When pressed on the signal, the pressed () set the change button

    ui->register_Button->setStyleSheet(QString::fromUtf8("background-color: rgb(0, 209, 202); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;"));
    

    How to return the button to its original state after moving the mouse to another place or after the button is triggered?

    J.HilkJ 1 Reply Last reply
    0
    • M Mikeeeeee

      Hi.
      How to change the display of the button when pressed?
      Initially set the button style:

       ui->register_Button->setStyleSheet(QString::fromUtf8("background-color: rgb(43, 104, 255); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;"));
      

      When pressed on the signal, the pressed () set the change button

      ui->register_Button->setStyleSheet(QString::fromUtf8("background-color: rgb(0, 209, 202); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;"));
      

      How to return the button to its original state after moving the mouse to another place or after the button is triggered?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      @Mikeeeeee

      QPushButton comes with a pressed state for your stylesheet ->

      ui->register_Button->setStyleSheet("QPushButton{background-color: rgb(43, 104, 255); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;} QPushButton:pressed{background-color: rgb(0, 209, 202); color:white; border: 3px solid white; padding: 5px; border-radius: 10px;}");
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1

      • Login

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