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. Qt 4.8 QSlider handle size
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8 QSlider handle size

Scheduled Pinned Locked Moved Solved General and Desktop
54 Posts 3 Posters 9.4k 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.
  • hskoglundH Offline
    hskoglundH Offline
    hskoglund
    wrote on last edited by
    #29

    Ok that could explain the different behavior, I never tested on Gentoo, sorry :-(

    SPlattenS 1 Reply Last reply
    0
    • hskoglundH hskoglund

      Ok that could explain the different behavior, I never tested on Gentoo, sorry :-(

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by
      #30

      @hskoglund , I thought I would take another look and I was wrong, looking at Qt Build & Run the compilers are:

      Auto-detected
          g++ (gnat-2014-4-x86)
          gcc (x86 64bit in /usr/bin)
          gcc (x86 32bit in /usr/bin)
      

      I then cleaned and rebuilt and can see in the Compiler Output it is using g++. I then opened a terminal and typed: g++ --version:

      g++ (Gentoo 4.6.3 p1.13, pie-0.5.2) 4.6.3
      

      So it looks like it is the same version after all.

      Kind Regards,
      Sy

      1 Reply Last reply
      0
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #31

        Hi I googled that Gentoo release and it seems that there's no online installation of Qt 4.8.4 available for it, so I think your version of Qt 4.8.4 is custom built, i.e. built by downloading the source for Qt 4.8.4 and compiling. And in that process some features might have been dropped, for example z-order for widgets.
        So I simplified my example to not to rely on a working z-order, please try this version:

        #include <QApplication>
        #include <qslider.h>
        
        class Window : public QWidget
        {
            Q_OBJECT
        
        // setup 2 real sliders and 2 "followers" that are stacked under the real ones
            QSlider* pSlider1;
            QSlider* pSlider1Follower;
            QSlider* pSlider2;
            QSlider* pSlider2Follower;
        
        public:
            Window()
            {
                setGeometry(130,130,860,660);
        
                pSlider1Follower = new QSlider(Qt::Horizontal,this);
                pSlider1Follower->setTickPosition(QSlider::TicksBothSides);
                pSlider1Follower->setTickInterval(2);
        
                pSlider2Follower = new QSlider(Qt::Vertical,this);
                pSlider2Follower->setTickPosition(QSlider::TicksBothSides);
                pSlider2Follower->setTickInterval(2);
        
                pSlider1 = new QSlider(Qt::Horizontal,this);
                pSlider2 = new QSlider(Qt::Vertical,this);
        
                connect(pSlider1,SIGNAL(valueChanged(int)),this,SLOT(valueChanged1(int)));
                connect(pSlider2,SIGNAL(valueChanged(int)),this,SLOT(valueChanged2(int)));
        
            // do an initial update/refresh
                valueChanged1(0);
                valueChanged2(0);
            }
        
        public slots:
            void valueChanged1(int value)
            {
                pSlider1Follower->setValue(value);
        
                pSlider2->setStyleSheet(QString("QSlider::groove { background: transparent; width: %1px; } "
               "QSlider::handle { background: #eeeeee; border:1px solid grey; height: %2px;}").arg(value + 30).arg(value * 2 + 10));
        
                pSlider2->setGeometry(660,30,2 * value + 30,600);
                pSlider2Follower->setGeometry(660,30,2 * value + 30,600);
            }
        
            void valueChanged2(int value)
            {
                pSlider2Follower->setValue(value);
        
                pSlider1->setStyleSheet(QString("QSlider::groove { background: transparent; height: %1px; } "
               "QSlider::handle { background: #eeeeee; border:1px solid grey; width: %2px;}").arg(value + 30).arg(value * 2 + 10));
        
                pSlider1->setGeometry(30,300,600,2 * value + 30);
                pSlider1Follower->setGeometry(30,300,600,2 * value + 30);
            }
        };
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
            Window window;
            window.show();
            return app.exec();
        }
        
        #include "main.moc"
        

        If it bulds ok, lets' debug:

        1. How many sliders do you see?
        2. If you move one of them, does it cause any other slider to move as well?
        3. If you move one of them, does it cause any other slider to change in size?
        SPlattenS 2 Replies Last reply
        0
        • hskoglundH hskoglund

          Hi I googled that Gentoo release and it seems that there's no online installation of Qt 4.8.4 available for it, so I think your version of Qt 4.8.4 is custom built, i.e. built by downloading the source for Qt 4.8.4 and compiling. And in that process some features might have been dropped, for example z-order for widgets.
          So I simplified my example to not to rely on a working z-order, please try this version:

          #include <QApplication>
          #include <qslider.h>
          
          class Window : public QWidget
          {
              Q_OBJECT
          
          // setup 2 real sliders and 2 "followers" that are stacked under the real ones
              QSlider* pSlider1;
              QSlider* pSlider1Follower;
              QSlider* pSlider2;
              QSlider* pSlider2Follower;
          
          public:
              Window()
              {
                  setGeometry(130,130,860,660);
          
                  pSlider1Follower = new QSlider(Qt::Horizontal,this);
                  pSlider1Follower->setTickPosition(QSlider::TicksBothSides);
                  pSlider1Follower->setTickInterval(2);
          
                  pSlider2Follower = new QSlider(Qt::Vertical,this);
                  pSlider2Follower->setTickPosition(QSlider::TicksBothSides);
                  pSlider2Follower->setTickInterval(2);
          
                  pSlider1 = new QSlider(Qt::Horizontal,this);
                  pSlider2 = new QSlider(Qt::Vertical,this);
          
                  connect(pSlider1,SIGNAL(valueChanged(int)),this,SLOT(valueChanged1(int)));
                  connect(pSlider2,SIGNAL(valueChanged(int)),this,SLOT(valueChanged2(int)));
          
              // do an initial update/refresh
                  valueChanged1(0);
                  valueChanged2(0);
              }
          
          public slots:
              void valueChanged1(int value)
              {
                  pSlider1Follower->setValue(value);
          
                  pSlider2->setStyleSheet(QString("QSlider::groove { background: transparent; width: %1px; } "
                 "QSlider::handle { background: #eeeeee; border:1px solid grey; height: %2px;}").arg(value + 30).arg(value * 2 + 10));
          
                  pSlider2->setGeometry(660,30,2 * value + 30,600);
                  pSlider2Follower->setGeometry(660,30,2 * value + 30,600);
              }
          
              void valueChanged2(int value)
              {
                  pSlider2Follower->setValue(value);
          
                  pSlider1->setStyleSheet(QString("QSlider::groove { background: transparent; height: %1px; } "
                 "QSlider::handle { background: #eeeeee; border:1px solid grey; width: %2px;}").arg(value + 30).arg(value * 2 + 10));
          
                  pSlider1->setGeometry(30,300,600,2 * value + 30);
                  pSlider1Follower->setGeometry(30,300,600,2 * value + 30);
              }
          };
          
          int main(int argc, char *argv[])
          {
              QApplication app(argc, argv);
              Window window;
              window.show();
              return app.exec();
          }
          
          #include "main.moc"
          

          If it bulds ok, lets' debug:

          1. How many sliders do you see?
          2. If you move one of them, does it cause any other slider to move as well?
          3. If you move one of them, does it cause any other slider to change in size?
          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #32

          @hskoglund , I’ll try this tomorrow and get back to you.

          Kind Regards,
          Sy

          1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi I googled that Gentoo release and it seems that there's no online installation of Qt 4.8.4 available for it, so I think your version of Qt 4.8.4 is custom built, i.e. built by downloading the source for Qt 4.8.4 and compiling. And in that process some features might have been dropped, for example z-order for widgets.
            So I simplified my example to not to rely on a working z-order, please try this version:

            #include <QApplication>
            #include <qslider.h>
            
            class Window : public QWidget
            {
                Q_OBJECT
            
            // setup 2 real sliders and 2 "followers" that are stacked under the real ones
                QSlider* pSlider1;
                QSlider* pSlider1Follower;
                QSlider* pSlider2;
                QSlider* pSlider2Follower;
            
            public:
                Window()
                {
                    setGeometry(130,130,860,660);
            
                    pSlider1Follower = new QSlider(Qt::Horizontal,this);
                    pSlider1Follower->setTickPosition(QSlider::TicksBothSides);
                    pSlider1Follower->setTickInterval(2);
            
                    pSlider2Follower = new QSlider(Qt::Vertical,this);
                    pSlider2Follower->setTickPosition(QSlider::TicksBothSides);
                    pSlider2Follower->setTickInterval(2);
            
                    pSlider1 = new QSlider(Qt::Horizontal,this);
                    pSlider2 = new QSlider(Qt::Vertical,this);
            
                    connect(pSlider1,SIGNAL(valueChanged(int)),this,SLOT(valueChanged1(int)));
                    connect(pSlider2,SIGNAL(valueChanged(int)),this,SLOT(valueChanged2(int)));
            
                // do an initial update/refresh
                    valueChanged1(0);
                    valueChanged2(0);
                }
            
            public slots:
                void valueChanged1(int value)
                {
                    pSlider1Follower->setValue(value);
            
                    pSlider2->setStyleSheet(QString("QSlider::groove { background: transparent; width: %1px; } "
                   "QSlider::handle { background: #eeeeee; border:1px solid grey; height: %2px;}").arg(value + 30).arg(value * 2 + 10));
            
                    pSlider2->setGeometry(660,30,2 * value + 30,600);
                    pSlider2Follower->setGeometry(660,30,2 * value + 30,600);
                }
            
                void valueChanged2(int value)
                {
                    pSlider2Follower->setValue(value);
            
                    pSlider1->setStyleSheet(QString("QSlider::groove { background: transparent; height: %1px; } "
                   "QSlider::handle { background: #eeeeee; border:1px solid grey; width: %2px;}").arg(value + 30).arg(value * 2 + 10));
            
                    pSlider1->setGeometry(30,300,600,2 * value + 30);
                    pSlider1Follower->setGeometry(30,300,600,2 * value + 30);
                }
            };
            
            int main(int argc, char *argv[])
            {
                QApplication app(argc, argv);
                Window window;
                window.show();
                return app.exec();
            }
            
            #include "main.moc"
            

            If it bulds ok, lets' debug:

            1. How many sliders do you see?
            2. If you move one of them, does it cause any other slider to move as well?
            3. If you move one of them, does it cause any other slider to change in size?
            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #33

            @hskoglund

            1. 2 Sliders, 1 horizontal and 1 vertical, with two handles on each, the horizontal slider handles do not look correct.

            2 . Moving the vertical slider causes both vertical handles to move together, the coloured square handle is correct orientation, this also increases height of horizontal slider.

            Moving the horizontal slider increases the width of the vertical slider, but the handles are not together, one is the correct orientation but centered.

            1. Vertical handles are in sync. Horizontal are not.

            Kind Regards,
            Sy

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #34

              Hi, is it possible for you to post a screenshot, for example when all the sliders are at about 50%?

              SPlattenS 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hi, is it possible for you to post a screenshot, for example when all the sliders are at about 50%?

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by SPlatten
                #35

                @hskoglund , unfortunately not, the development system is so locked down, I cannot get anything off the system, which is why when I post there are often errors in syntax because I have to retype it.

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #36

                  If you have a mobile phone with a camera, is it possible you could take a picture of the screen using your mobile phone?

                  SPlattenS 1 Reply Last reply
                  0
                  • hskoglundH hskoglund

                    If you have a mobile phone with a camera, is it possible you could take a picture of the screen using your mobile phone?

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by SPlatten
                    #37

                    @hskoglund , I can't paste the photo into this forum, it just gives the file URL.

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by
                      #38

                      Sometimes it's tricky to post a picture into this forum from a mobile phone :-(
                      If you have email installed on your phone, you could try emailing the picture to yourself, then open that picture on a computer and post it from there...

                      SPlattenS 2 Replies Last reply
                      0
                      • hskoglundH hskoglund

                        Sometimes it's tricky to post a picture into this forum from a mobile phone :-(
                        If you have email installed on your phone, you could try emailing the picture to yourself, then open that picture on a computer and post it from there...

                        SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by
                        #39

                        @hskoglund I have the photo and emailed it to myself, but I cannot access my email (personal) from these computers...it will have to wait until I get home later tonight.

                        Kind Regards,
                        Sy

                        1 Reply Last reply
                        0
                        • hskoglundH hskoglund

                          Sometimes it's tricky to post a picture into this forum from a mobile phone :-(
                          If you have email installed on your phone, you could try emailing the picture to yourself, then open that picture on a computer and post it from there...

                          SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #40

                          @hskoglund , please see screenshot taken with phone:
                          14fba285-9f08-4a9d-8b28-3434397c5069-image.png
                          cid:3BAF623A-7AF5-4E01-BE6B-D9971912745D

                          Kind Regards,
                          Sy

                          1 Reply Last reply
                          0
                          • hskoglundH Offline
                            hskoglundH Offline
                            hskoglund
                            wrote on last edited by
                            #41

                            Hi, as you say, the vertical slider looks ok but not the horizontal one. Sure you copied my program ok? If you check with wc it should say:

                            70  166 2117 main.cpp
                            

                            and the md5 sum:

                            md5sum main.cpp
                            1eaf936e1072bf34bbb817a942295ada  main.cpp
                            

                            could you take a photo of the code after public slots: it should look like this:

                            Screenshot 2022-04-08 at 08.11.38.png

                            Sorry to bother but over the years, many times I've been struck by that "not copied verbatim" bug...

                            SPlattenS 2 Replies Last reply
                            0
                            • hskoglundH hskoglund

                              Hi, as you say, the vertical slider looks ok but not the horizontal one. Sure you copied my program ok? If you check with wc it should say:

                              70  166 2117 main.cpp
                              

                              and the md5 sum:

                              md5sum main.cpp
                              1eaf936e1072bf34bbb817a942295ada  main.cpp
                              

                              could you take a photo of the code after public slots: it should look like this:

                              Screenshot 2022-04-08 at 08.11.38.png

                              Sorry to bother but over the years, many times I've been struck by that "not copied verbatim" bug...

                              SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by
                              #42

                              @hskoglund , I work remotely 300 miles away from where I live, I'm home now and will be back at the system on Monday, I'll take a look and get back to you on Monday.

                              Kind Regards,
                              Sy

                              1 Reply Last reply
                              0
                              • hskoglundH hskoglund

                                Hi, as you say, the vertical slider looks ok but not the horizontal one. Sure you copied my program ok? If you check with wc it should say:

                                70  166 2117 main.cpp
                                

                                and the md5 sum:

                                md5sum main.cpp
                                1eaf936e1072bf34bbb817a942295ada  main.cpp
                                

                                could you take a photo of the code after public slots: it should look like this:

                                Screenshot 2022-04-08 at 08.11.38.png

                                Sorry to bother but over the years, many times I've been struck by that "not copied verbatim" bug...

                                SPlattenS Offline
                                SPlattenS Offline
                                SPlatten
                                wrote on last edited by
                                #43

                                @hskoglund, I've been through the source again an yes there was an error in the CSS, which having corrected this what I'm seeing is still four handles, where the underlying handles are orientated incorrectly, the handles on-top of these are orientated as I would expected.

                                Moving the vertical slider increases the width of the horizontal slider.
                                Moving the horizontal slider increases the height of the vertical slider.

                                Kind Regards,
                                Sy

                                1 Reply Last reply
                                0
                                • hskoglundH Offline
                                  hskoglundH Offline
                                  hskoglund
                                  wrote on last edited by
                                  #44

                                  Hi, if you're seeing four handles now, if I look at your screenshot above, I see only three handles.
                                  Could you take a picture of the code now after you've corrected it?

                                  1 Reply Last reply
                                  0
                                  • SPlattenS Offline
                                    SPlattenS Offline
                                    SPlatten
                                    wrote on last edited by
                                    #45

                                    Its only 3 because the vertical handles are tracking and it was resized to obscure the one under it. Now the CSS is fixed both sets of handles move together.

                                    I can't really do the screen shot until Thursday so I'm hoping it isn't required?

                                    Kind Regards,
                                    Sy

                                    1 Reply Last reply
                                    0
                                    • hskoglundH Offline
                                      hskoglundH Offline
                                      hskoglund
                                      wrote on last edited by
                                      #46

                                      Aha nice! So if they move together (both horizontally and vertically) that means your screen now looks similar to my screenshot 5 days ago?
                                      Which means you can use this as a solution for displaying classical grooves and simultaneously having resizable QSlider handles on your Qt 4.8.4...

                                      SPlattenS 1 Reply Last reply
                                      0
                                      • hskoglundH hskoglund

                                        Aha nice! So if they move together (both horizontally and vertically) that means your screen now looks similar to my screenshot 5 days ago?
                                        Which means you can use this as a solution for displaying classical grooves and simultaneously having resizable QSlider handles on your Qt 4.8.4...

                                        SPlattenS Offline
                                        SPlattenS Offline
                                        SPlatten
                                        wrote on last edited by
                                        #47

                                        @hskoglund , I'm just a little confused as to why you chose to show four sliders when only two are required?

                                        Kind Regards,
                                        Sy

                                        1 Reply Last reply
                                        0
                                        • hskoglundH Offline
                                          hskoglundH Offline
                                          hskoglund
                                          wrote on last edited by
                                          #48

                                          I tried lots of variations with just one QSlider, but couldn’t find a way to both have a resizable handle and proper grooves.
                                          So by introducing one extra ”dummy” QSlider hidden underneath, was a way out of this dilemma.

                                          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