![](/img/trans.png)
[英]In a Django Forms drop-down list, how do I show text accessed via a foreign key?
[英]How to do custom drop-down list in QGIS plugin ( PYQT ) like identify tool
我目前正在开发 Qgis Python 插件,现在我需要请求用户从列表中输入一个项目。 但我不知道如何制作自定义下拉列表,我通过 inte.net 进行了研究,但找不到解决方案,你能帮我制作一个自定义下拉列表吗?识别工具 QGIS ( )
我尝试使用 combobox 小部件来做,但我需要一个列表来选择项目,你能帮我解决这个问题吗,我附上了示例列表的照片
我相信前面的问题有你的答案: Qt/PyQt: How do I create a drop down widget, such as a QLabel, QTextBrowser, etc.?
归功于 ekhumoro:
这是他的代码:
from PyQt5 import QtGui, QtCore
class Window(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
layout = QtGui.QHBoxLayout(self)
self.button = QtGui.QToolButton(self)
self.button.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
self.button.setMenu(QtGui.QMenu(self.button))
self.textBox = QtGui.QTextBrowser(self)
action = QtGui.QWidgetAction(self.button)
action.setDefaultWidget(self.textBox)
self.button.menu().addAction(action)
layout.addWidget(self.button)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
window = Window()
window.resize(100, 60)
window.show()
sys.exit(app.exec_())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.