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. QDial does not expand

QDial does not expand

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 799 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.
  • S Offline
    S Offline
    Simof
    wrote on last edited by
    #1

    Dear all,
    I made a custom class that hinerited from QDial and called PowerDial.
    I don't understand because does not growing up to sizeHint if the policy is MinimumExpanding.

    void Run::makePowerDial(void)
    {
        rightLayoutPower = new QVBoxLayout();
        QLabel* label = new QLabel(Translator::GetInstance().get("power"));
        label->setAlignment(Qt::AlignCenter);
    
        PowerDial* powerDial = new PowerDial(40, 20);
        powerDial->setValue(5);
    
        powerDial->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    
        rightLayoutPower->addWidget(powerDial, 9, Qt::AlignCenter);
        rightLayoutPower->addWidget(label, 1, Qt::AlignCenter);
    }
    

    Inside the class are overridden the funcions:

    int PowerDial::heightForWidth(int width) const
    {
        return width;
    }
    
    QSize PowerDial::sizeHint() const
    {
        return QSize(200, 200);
    }
    
    QSize PowerDial::minimumSizeHint() const
    {
        return QSize(100, 100);
    }
    
    bool PowerDial::hasHeightForWidth() const
    {
        return true;
    }
    
    void PowerDial::resizeEvent(QResizeEvent *event)
    {
    
    }
    

    2021-07-13 11_03_55-Window.png

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

      Hi
      What happens if you remove the empty resizeEvent ?

      S 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        What happens if you remove the empty resizeEvent ?

        S Offline
        S Offline
        Simof
        wrote on last edited by
        #3

        @mrjj

        Nothing!

        If the sizeHint is greater respect the available area the widget is reduced correctly but if his sizeHint is smaller then the available area It keep the sizeHint area.

        mrjjM 1 Reply Last reply
        0
        • S Simof

          @mrjj

          Nothing!

          If the sizeHint is greater respect the available area the widget is reduced correctly but if his sizeHint is smaller then the available area It keep the sizeHint area.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Simof
          Ok. thats a bit odd.
          Did you try with plain QSizePolicy::Expanding ?

          S 1 Reply Last reply
          0
          • mrjjM mrjj

            @Simof
            Ok. thats a bit odd.
            Did you try with plain QSizePolicy::Expanding ?

            S Offline
            S Offline
            Simof
            wrote on last edited by
            #5

            @mrjj Yes, I tried every type of Policy

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Simple check - created an empty widget, added a QDial and put it in a QGridLayout - it's expanding to the widgets size. Tested with QtDesigner and QtCreator (both Qt5.15) . So there must be something wrong on your side. Please provide a minimal, compilable example.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • S Offline
                S Offline
                Simof
                wrote on last edited by
                #7

                I tried with a QDial without any customization and the result is the same.

                2021-07-14 08_18_58-Window.png

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What Qt style do you use?

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  S 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    What Qt style do you use?

                    S Offline
                    S Offline
                    Simof
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher

                    The fusion style

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Also works fine for me with the fusion style on linux with Qt5.15. Please exactly follow my testcase to see if this works for you or not.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      S 1 Reply Last reply
                      0
                      • Christian EhrlicherC Christian Ehrlicher

                        Also works fine for me with the fusion style on linux with Qt5.15. Please exactly follow my testcase to see if this works for you or not.

                        S Offline
                        S Offline
                        Simof
                        wrote on last edited by
                        #11

                        @Christian-Ehrlicher

                        If the dial is used in a new empty project it works fine!
                        What I could be have broken in my project?

                        2021-07-14 13_10_53-Window.png

                        Christian EhrlicherC 1 Reply Last reply
                        0
                        • S Simof

                          @Christian-Ehrlicher

                          If the dial is used in a new empty project it works fine!
                          What I could be have broken in my project?

                          2021-07-14 13_10_53-Window.png

                          Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Simof said in QDial does not expand:

                          What I could be have broken in my project?

                          Reduce your project until it works, or create a testaplication and try to add your stuff until it no longer works - basic programming stuff :)

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          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