gpt4 book ai didi

c++ - QSlider 增加 handle 尺寸

转载 作者:太空狗 更新时间:2023-10-29 20:02:02 26 4
gpt4 key购买 nike

我非常需要增加我的 slider 的句柄大小,但是没有 css 选项可以做到这一点 (styleSheet())。Qt 文档中的默认示例也没有帮助我。

我有一个像这样的 slider : I have slider like this

我想增加 handle 的高度,如下图所示,但我不知道该怎么做。可能唯一的方法是子类化 QAbstractSlider?

explanation image

这是我的代码中的样式表:

                "QSlider::groove:horizontal {"
"border: 1px solid #999999;"
"height: 32px;" /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
"background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);"
"margin: 2px 0; }"
"QSlider::handle:horizontal {"
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);"
"border: 1px solid #5c5c5c;"
"width: 40px;"
"margin: -20px 0;" /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
"border-radius: 3px;}"
);

最佳答案

使用这个样式表:

.QSlider {
min-height: 68px;
max-height: 68px;
background: #5F4141;
}

.QSlider::groove:horizontal {
border: 1px solid #262626;
height: 5px;
background: #393939;
margin: 0 12px;
}

.QSlider::handle:horizontal {
background: #22B14C;
border: 5px solid #B5E61D;
width: 23px;
height: 100px;
margin: -24px -12px;
}

它将产生以下内容:

image

请注意,通过将 min-heightmax-height 设置为相同的值,可以使 slider 的高度保持不变。

关于c++ - QSlider 增加 handle 尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47691972/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com