问题标签 [qcombobox]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
902 浏览

qt - 添加新项目时,QCombobox 与其他小部件重叠

我看到 QComboBox 发生了这种奇怪的行为,它不会在其内容更改后立即更新。为了演示这里的问题是一个示例代码和一些屏幕截图。

初始小部件 在此处输入图像描述

将项目添加到组合框在此处输入图像描述(查看复选框如何重叠)

手动调整大小更新并调整布局和组合框在此处输入图像描述

我在组合框上尝试了 update() 和 repaint() 以及项目被编辑后的布局,但没有任何效果。我真的必须手动调整组合框的小部件大小才能重新调整吗?有没有人知道这个问题的修复?

谢谢你。

简历

0 投票
1 回答
1416 浏览

python - PyQt4 QComboBox 信号和插槽

有没有办法创建一个信号,该信号在打开组合框并且用户使用键盘上的向上 - 向下箭头选择项目时断言。到目前为止,Qt4 参考列出了仅在单击鼠标或返回键后才激活的信号。我尝试了 highlight(int) 并且仅在再次单击鼠标时才有效,但是当我使用向上/向下箭头时,仅检索到单击的第一个项目。我认为当前突出显示的索引是通过 self.ui.cb_dspBenchCmds.currentText() 返回的索引。

这是一个代码片段:

谢谢

戴夫

0 投票
3 回答
22442 浏览

qt - QComboBox 下拉列表 - 设置选中项样式

是否可以设置 QComboBox 下拉列表的选定项样式(Qt 样式表)?

0 投票
3 回答
68796 浏览

python - 如何在 PyQt/PySide 中将项目添加到 QComboBox

我需要一些帮助,将一些项目添加到QComboBox. 所以我有两个组合框,一个根据所选项目填充另一个。

我的问题是,additem用于新项目,它可以工作,但如果我为组合框选择另一个选项,它会添加新项目,但以前的项目已经消失 - 并且新项目下方有空白项目。

我以为每次我从第一个组合框中选择一个新选项来清除第二个组合框的内容。所以我clear()在第二个上使用了 - 但它没有用。

我就是这么想的:

以上是第一个combobox更改时执行的函数的一部分。

0 投票
1 回答
2615 浏览

python - pyqt4 QComboBox setEditable(True) - 如何设置MaxLength?

我有一个与数据库 VARCHAR(45) 字段绑定的 QComboBox。

QComboBox 下拉列表提供了一组默认值,但它已启用 EDIT,用户可以在其中输入任何内容。

我想将用户输入长度限制为最多 45 个字符

QComboBox 没有像 QLineEdit 那样的 setMaxLength(int) 。

有人有什么建议吗?

谢谢

0 投票
1 回答
2302 浏览

qt - 如果选择了 QComboBox 中的某个值,则停用 QSpinBox

如果在 QComboBox 中选择了某个值,是否可以停用 QSpinBox。我已经尝试了几件事,但是 QSpinbox 要么一直处于停用状态,要么根本不会停用。

0 投票
1 回答
1341 浏览

python - PyQt4:我可以拦截 QComboBox 的 currentIndexChanged 信号吗?

我建立了一个由 QComboBox 和 QGraphicsScene 组成的 UI,它是 QGraphicsItems。

当我更改 QComboBox 的索引时,刷新 QGraphicsScene 使其设置为默认值。为了解决它,我将几何信息存储到节点。它运作良好。

这时,我想确定QGraphicsItems被修改了,它们的geo-infos没有被存储。因此,UI 通知用户他或她必须存储它们。

我希望它在更改 QComboBox 时发生,为此我必须拦截 currentIndexChanged 信号。这意味着QComboBox在实际更改索引之前,它会读取标志并对用户做一些事情,并且不会错过QComboBox返回到先前索引的地理信息。

0 投票
1 回答
910 浏览

qt - 具有 NULL 支持的 QComboBox

QComboBox用来从 Units 表中选择单位(对象的任意属性)。问题是我的数据模型中的对象可以没有单位(表中的 NULL),在这种情况下QComboBox显示值发生在列表的顶部。选择“无”是不可能的。
您建议添加 NULL 支持什么?我有几个版本:

  1. 在名为“--”或“N/A”的单位表中插入特殊记录。不完全是 NULL - 会有自己的 id。
  2. 手动设置项目QComboBox并更新模型。可能但乏味 - 再见单元列表的自动更新。

还有什么可能 - 子类化QComboBox(覆盖什么)?我没有看到任何类似于setEditorData/setModelData喜欢的东西QAbstractItemDelegate来控制项目。

0 投票
3 回答
11563 浏览

qt - 样式 QComboBox 弹出菜单边距 Qt 4

经过无数小时尝试设置 QComboBox 的样式后,我被插入项目的顶部和底部边距卡住了。

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

QComboBox 屏幕 http://img576.imageshack.us/img576/3402/screenshot20120130at144.png

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

谢谢你的帮助。

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

0 投票
1 回答
13083 浏览

python-3.x - Separate user interaction from programmical change: PyQt, QComboBox

I have several QComboBoxes in my PyQt4/Python3 GUI and they are filled with some entries from a database during the initialisation. Initial CurrentIndex is set to 0. There is also a tick box which changes the language of the items in my combo boxes. To preserve current user selection I backup index of the current item and setCurrentIndex to this number after I fill in ComboBox with translated items. All those actions emit currentIndexChanged signal.

Based on the items selected in QComboBoxes some plot is displayed. The idea is to redraw the plot online - as soon as the user changes any of ComboBox current item. And here I have a problem since if I redraw the plot every time signal currentIndexChanged is emited, I redraw it also several times during initialization and if the translation tick box selection was changed.

What is the best way to separate these cases? In principle I need to separate programmical current Index Change from the user, and update the plot only in the later case (during GUI initialisation I can programically call update plot function once). Should I write/rewrite any signal? If so, I never did that before and would welcome any hint or a good example. Use another signal? Or maybe there is a way to temporary block all signals?