Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
样式QComboBox弹出菜单页边距Qt 4_Qt_Stylesheet_Qcombobox - Fatal编程技术网

样式QComboBox弹出菜单页边距Qt 4

样式QComboBox弹出菜单页边距Qt 4,qt,stylesheet,qcombobox,Qt,Stylesheet,Qcombobox,在无数个小时尝试设计一个QComboBox之后,我被插入项目的顶部和底部边距卡住了 我想删除或应用背景色弹出菜单顶部和底部的空白 我在QListView中添加了一个最小高度,以不显示顶部和底部箭头。我还查看了Qt源代码中的qcomboxprivate类,但似乎上下页边距都是硬编码的 谢谢你的帮助 编辑:这是到目前为止我的样式表 QComboBox { border: 1px solid rgb(95, 95, 95); border-radius: 3px; paddi

在无数个小时尝试设计一个QComboBox之后,我被插入项目的顶部和底部边距卡住了

我想删除或应用背景色弹出菜单顶部和底部的空白

我在QListView中添加了一个最小高度,以不显示顶部和底部箭头。我还查看了Qt源代码中的qcomboxprivate类,但似乎上下页边距都是硬编码的

谢谢你的帮助

编辑:这是到目前为止我的样式表

QComboBox {
    border: 1px solid rgb(95, 95, 95);
    border-radius: 3px;
    padding: 1px 18px 1px 3px;
    min-width: 6em;
    color: rgb(220, 220, 220);
    background-color: rgb(80, 80, 80);
    margin: 0 0 0 0;
}

QComboBox:editable {
    background: rgb(80, 80, 80);
}

QComboBox:!editable {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                  stop: 0 rgb(51, 51, 51), stop: 0.4 rgb(39, 39, 39),
                                  stop: 0.5 rgb(32,32,32), stop: 1.0 rgb(38,38,38));;
}

QComboBox::drop-down:editable {
}

QComboBox:!editable:on {
}

QComboBox::drop-down:editable:on {
}

QComboBox:on { /* shift the text when the popup opens */
    padding-top: 3px;
    padding-left: 4px;
    background-color: rgb(80, 80, 80);
}

QComboBox::drop-down {
    subcontrol-origin: padding;
    subcontrol-position: center right;
    width: 15px; 
    right:3px;
    border-top-right-radius: 3px; /* same radius as the QComboBox */
    border-bottom-right-radius: 3px;
    background:none;
}

QComboBox::down-arrow {
    image: url(:/images/arrow-down-inverted.png);
    height: 10px;
}

QComboBox::down-arrow:on { /* shift the arrow when popup is open */
    top: 1px;
    left: 1px;
}

QListView#comboListView {
    background: rgb(80, 80, 80);
    color: rgb(220, 220, 220);
    min-height: 90px;
    margin: 0 0 0 0;
}

QListView#comboListView::item {
    background-color: rgb(80, 80, 80);
}

QListView#comboListView::item:hover {
    background-color: rgb(95, 95, 95);
}

请尝试以下样式表:

QComboBox {
  margin-top: 0px;
  margin-bottom: 0px;
}

这应该将边距设置为0。还有对样式表的qt引用。

我发现删除白边的解决方案是将组合框设置为只读

QCombobox* choiceBox = new QCombobox;
choiceBox->lineEdit()->setReadOnly(true);

您需要自定义
QComboBox
中的
QAbstractItemView

QComboBox QAbstractItemView {
    margin-top: 0px;
    padding-bottom: 0px;
}

你能发布到目前为止的样式表吗?这里同样的问题,看起来它是由QComboBox的填充引起的。但是当:on state时将其设置为0没有帮助:/n它设置QCombobox的边距,而不是内部菜单的边距。