带有 QPushButton、QComboBox QCheckbox 的动态小部件列表
我想创建一个列表,该列表中的每一行包含:
LineNo | Edit Model | Model Select | Log enabl | freq | selection |
1 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
2 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
3 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
| | | | | | |
n | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
该列表是动态的,我总共有 36 个模型,但仅应根据已做出的选择来表示其中的一部分。用户应该能够后悔之前的任何选择并重新绘制此列表。
我一直在研究 QListView、QTableWidget、Delegates,但我似乎找不到任何关于如何将 QPushButton 实现到 QListView 或 QTableWidget 中的示例或教程。查看 QItemDeligate 的文档 QPushButton 不属于可接受的类型。
I'd like to create a list, each row in this list contains:
LineNo | Edit Model | Model Select | Log enabl | freq | selection |
1 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
2 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
3 | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
| | | | | | |
n | QPushButton | QComboBox | QCheckBox | QLineEdit | QLineEdit |
This list is dynamic, i have a total of 36 models but only a selection of these should be represented depending on choices that has been made. The user sould be able to regret any earlier choices and redraw this list.
I have been looking at QListView, QTableWidget, Delegates, but i cant seem to find any examples or turorials on how to implement QPushButton into either QListView or QTableWidget. Looking at the documentation of QItemDeligate QPushButton are not among the accepted types.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您正在寻找以下功能之一(取决于您使用的视图类):
这将允许您在所需位置显示任意小部件,无需与委托进行混杂。
请注意,这些函数仅在这些视图的“Widget”版本中可用(例如 QTreeWidget,而不是 QTreeView)。然而,QAbstractItemView 中有一个 setIndexWidget() 函数也可以使用。
I believe you're looking for one of the following functions (depending on which view class you're using):
This will allow you to display an arbitrary widget in the desired location, no mucking with delegates required.
Note that these functions are only available in the "Widget" versions of these views (e.g. QTreeWidget as opposed to QTreeView). However there is a setIndexWidget() function in QAbstractItemView that can be used as well.