首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >QComboBox ListView正在运行组合框框架

QComboBox ListView正在运行组合框框架
EN

Stack Overflow用户
提问于 2018-06-15 06:30:32
回答 1查看 787关注 0票数 1

combobox包含两个条目,当单击组合框时,列表视图占据组合框的框架。我要在组合框下面的列表视图。样式表如下所示:

代码语言:javascript
运行
复制
QComboBox {
border: 1px solid #8F9EAB;
border-radius: 3px;
font: 16pt "Arial";
min-width: 6em;
color: #1B3067;
background-color: rgb(255, 255, 255);
padding-left:10px;
} 
QComboBox:pressed
{
border: 1px solid #1562AD; 
color: rgb(255, 255, 255);
background-color: #87A6D5;
} 
QComboBox:disabled
{
border: 1px solid #BFBFBF; 
color: #BFBFBF;
background-color: rgb(255, 255, 255);
} 
QComboBox::down-arrow
{ 
background-image: url(:/Images/data/img/Images/DOWN_enabled.png);
height: 7px;
width : 13px;
}
QComboBox::drop-down 
{ 
subcontrol-position: top right;
width: 40px;
color: white;
border-left-width: 0px;
border-left-color: #8F9EAB;
border-left-style: solid; 
border-top-right-radius: 3px;
border-bottom-right-radius: 3px; 
}
QComboBox QListView
{
font: 16pt "Arial";
color: rgb(80, 80, 80);
}
QComboBox QAbstractItemView::item 
{
border-bottom: 5px solid white; margin:3px;
}
EN

Stack Overflow用户

回答已采纳

发布于 2018-06-15 07:43:14

Qt样式表无法处理view()的位置,您必须创建一个继承自QComboBox并覆盖showPopup()方法的类,如下所示。

代码语言:javascript
运行
复制
class ComboBox: public QComboBox{
public:
    using QComboBox::QComboBox;
public:
    void showPopup(){
        QComboBox::showPopup();
        QPoint pos = mapToGlobal(QPoint(0, height()));
        view()->parentWidget()->move(pos);
    }
};

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50870221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档