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. StyleSheet
Qt 6.11 is out! See what's new in the release blog

StyleSheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 549 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.
  • privatepepperP Offline
    privatepepperP Offline
    privatepepper
    wrote on last edited by privatepepper
    #1

    Hello

    Why when I set stylesheet for my QPushButton:hover background, the background area is bigger than an actual QPushButton?

    My code:

    button->setStyleSheet("QPushButton:hover { background: Red;}");
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt ?
      On what platform ?
      What are you getting ?
      Can you provide a minimal compilable example that shows that behaviour ?

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

      privatepepperP 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What version of Qt ?
        On what platform ?
        What are you getting ?
        Can you provide a minimal compilable example that shows that behaviour ?

        privatepepperP Offline
        privatepepperP Offline
        privatepepper
        wrote on last edited by
        #3

        @SGaist

        I am using Qt creator and my Qt version is 5.14.2
        My OS - MacOs Catalina

        100522474_1901850159946056_4610327412897480704_n.jpg

        100923536_274199117067430_5968441431042293760_n.jpg

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

          Can you provide a minimal compilable example ?

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

          privatepepperP 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you provide a minimal compilable example ?

            privatepepperP Offline
            privatepepperP Offline
            privatepepper
            wrote on last edited by privatepepper
            #5

            @SGaist

            widget.cpp:

            #include "widget.h"
            #include "ui_widget.h"
            #include <QPushButton>
            
            Widget::Widget(QWidget *parent)
                : QWidget(parent)
                , ui(new Ui::Widget)
            {
                ui->setupUi(this);
            
                auto button = new QPushButton(this);
                button->setStyleSheet("QPushButton:hover { background: Red;}");
            
            }
            

            widget.h:

            #ifndef WIDGET_H
            #define WIDGET_H
            
            #include <QWidget>
            
            QT_BEGIN_NAMESPACE
            namespace Ui { class Widget; }
            QT_END_NAMESPACE
            
            class Widget : public QWidget
            {
                Q_OBJECT
            
            public:
                Widget(QWidget *parent = nullptr);
                ~Widget();
            
            private:
                Ui::Widget *ui;
            };
            #endif // WIDGET_H
            

            main.cpp:

            #include "widget.h"
            
            #include <QApplication>
            
            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                Widget w;
                w.show();
                return a.exec();
            }
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              If you a better looking button with style sheets, you should take a look at the customizing QPushButton example in the Qt Stylesheet reference.

              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