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. QSlider does not look as supposed to in QGraphicsProxyWidget
Qt 6.11 is out! See what's new in the release blog

QSlider does not look as supposed to in QGraphicsProxyWidget

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

    Hi,
    I did this in my QGraphicsView:

        proxy = new QGraphicsProxyWidget();
        zoomSlider = new QSlider(Qt::Vertical);
        QFile sliderStylesheetFile(":/CustomStylesheets/Slider_Stylesheet.txt");
        sliderStylesheetFile.open(QIODevice::ReadOnly | QIODevice::Text);
        QString sliderStylesheet = sliderStylesheetFile.readAll();
        zoomSlider->setStyleSheet(sliderStylesheet);
        zoomSlider->setGeometry(0, 0, 50, 150);
        proxy->setWidget(zoomSlider);
        scene->addItem(proxy);
        proxy->setPos(mapToScene(0, 0));
    

    after that, I scale the proxy often, but this shouldn't affect the slider widget itself but except that, I'm not doing anything with the slider or the proxy.
    But the slider looks like this:
    0_1536076095401_Qt 35.png
    It should look like this (I used the same stylesheet for both, but the following isn't in a QGraphicsProxyWidget):
    0_1536076402223_Qt 36.png
    If it helps, I use the following stylesheet:

    QSlider::groove:vertical
    {
    border: 1px solid #bbb;
    background: white;
    width: 10px;
    border-radius: 4px;
    }
    
    QSlider::sub-page:vertical
    {
    background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #fff, stop: 0.4999 #eee, stop: 0.5 #ddd, stop: 1 #eee );
    border: 1px solid #777;
    width: 10px;
    border-radius: 4px;
    }
    
    QSlider::add-page:vertical {
    background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #78d, stop: 0.4999 #46a, stop: 0.5 #45a, stop: 1 #238 );
    
    border: 1px solid #777;
    width: 10px;
    border-radius: 4px;
    }
    
    QSlider::handle:vertical {
    background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #eee, stop:1 #ccc);
    border: 1px solid #777;
    height: 13px;
    margin-top: -2px;
    margin-bottom: -2px;
    border-radius: 4px;
    }
    
    QSlider::handle:vertical:hover {
    background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd);
    border: 1px solid #444;
    border-radius: 4px;
    }
    
    QSlider::sub-page:vertical:disabled {
    background: #bbb;
    border-color: #999;
    }
    
    QSlider::add-page:vertical:disabled {
    background: #eee;
    border-color: #999;
    }
    
    QSlider::handle:vertical:disabled {
    background: #eee;
    border: 1px solid #aaa;
    border-radius: 4px;
    }
    

    I am using Qt 5_9_1 and am running on Windows 10.
    Any idea, what I have forgotten?
    Thanks for answers!

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

      Hi,

      You should add which version of Qt you are using as well as the platform you are running on.

      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
      1
      • NiagarerN Offline
        NiagarerN Offline
        Niagarer
        wrote on last edited by
        #3

        Ok, with another stylesheet it works. But what is the mistake in the stylesheet I showed in the question?

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

          Can you show the working stylesheet ?

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

          NiagarerN 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you show the working stylesheet ?

            NiagarerN Offline
            NiagarerN Offline
            Niagarer
            wrote on last edited by
            #5

            Well, it's really really strange... I can't reproduce the problem now... I do exactely, what is pasted in the question and it works now... did restarting qt creator fix it in the end!? It is exactely the same project, but now it works

            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