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. QMessage box buttons size/others have incorrect width after setting style.

QMessage box buttons size/others have incorrect width after setting style.

Scheduled Pinned Locked Moved Solved General and Desktop
qssqstylesheetqstyleqpalettefusion
7 Posts 2 Posters 1.0k 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 13 Nov 2021, 19:09 last edited by
    #1

    Hey
    More or less this is my flow
    Start app
    Create pallette
    Create Style fusion
    Apply style/palette/etc
    Then I load my qss file with some overrides & load that & apply to qapp to entire app.
    Once I do that, when I look at my buttons, they are all at "minimum" width size. QMessageBox "OK" button is like 20 pixels wide.

    If I do not apply my qss, everything works as it should.
    How can I bite this ? Is there any rule in CSS that I Can specify on per button bassis to somehow "retain" accurate width ?
    TIA

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dariusz
      wrote on 13 Jan 2022, 19:16 last edited by
      #7

      I finally got it solved...

      The fix was:

      QPushButton {
          width: 100%;
      }
      

      :- )

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 13 Nov 2021, 19:46 last edited by
        #2

        Hi,

        How do you specify your style sheet ?

        If you are not precise enough, it will just apply to everything.

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

        D 1 Reply Last reply 13 Nov 2021, 20:09
        0
        • S SGaist
          13 Nov 2021, 19:46

          Hi,

          How do you specify your style sheet ?

          If you are not precise enough, it will just apply to everything.

          D Offline
          D Offline
          Dariusz
          wrote on 13 Nov 2021, 20:09 last edited by
          #3

          @SGaist
          Something like this:

          auto style = QFile(":/styleThemes/styleDark");
          style.open(QIODevice::ReadOnly);
          qApp.setStyleSheet(style.readAll());
          

          Style has stuff like

          QPushButton{
          }
          

          That I set on the app, it removes the native Fusion style & at the same time button wont size-width properly.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 13 Nov 2021, 20:18 last edited by
            #4

            So it's exactly what I wrote: that style is applied to all the QPushButtons of your application.

            Using stylesheet on a widget will replace it's style by the one used to handle the stylesheet.

            If you only want to apply it on a specific button, then you have to write it accordingly.

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

            D 1 Reply Last reply 13 Nov 2021, 20:46
            1
            • S SGaist
              13 Nov 2021, 20:18

              So it's exactly what I wrote: that style is applied to all the QPushButtons of your application.

              Using stylesheet on a widget will replace it's style by the one used to handle the stylesheet.

              If you only want to apply it on a specific button, then you have to write it accordingly.

              D Offline
              D Offline
              Dariusz
              wrote on 13 Nov 2021, 20:46 last edited by
              #5

              @SGaist Yes, I want to apply style to entire aspp. But I don't want to affect button width sizing using the style. None of my QPushButton{} options change any width sizing related settings. I suppose as it removed fusion by default it also removes some width sizing aprameter of a button. So I wonder what style-width-parameter do I have to re-configure to retain it?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 14 Nov 2021, 19:44 last edited by
                #6

                Depending on your exact issue, give size information for the buttons that do not show as you want.

                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
                • D Offline
                  D Offline
                  Dariusz
                  wrote on 13 Jan 2022, 19:16 last edited by
                  #7

                  I finally got it solved...

                  The fix was:

                  QPushButton {
                      width: 100%;
                  }
                  

                  :- )

                  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