单击pyqt5

问题描述

单击QMainWindow上的按钮时,PYQT5演示将显示模式自定义QDialog窗口.QDialog具有带有QCompleter的QLineEdit.Key Down&Up可用于选择弹出项,但我不能使用鼠标单击并选择这也是因为弹出视图被冻结。我也想仅当使用鼠标单击该项目时,弹出项目文本才不会自动添加到QLineEdit中。

import sys
from PyQt5.QtWidgets import QMainWindow,QApplication,QPushButton,QWidget,QVBoxLayout,QDialog,QLineEdit,QCompleter

items_list = ['John Doe','Jane Doe','Albert Einstein','Alfred E Newman']


class SecondDialog(QDialog):
    def __init__(self):
        super(SecondDialog,self).__init__()
        self.v_layout = QVBoxLayout()
        self.my_edit = QLineEdit()
        self.completer = QCompleter(items_list)
        self.my_edit.setCompleter(self.completer)
        self.v_layout.addWidget(self.my_edit)
        self.setLayout(self.v_layout)

class MyWindows(QMainWindow):
    def __init__(self):
        super(MyWindows,self).__init__()
        self.widget = QWidget()
        self.v_layout = QVBoxLayout(self.widget)
        self.my_btn = QPushButton("Open second Dialog")
        self.my_btn.clicked.connect(self.openDialog)
        self.v_layout.addWidget(self.my_btn)
        self.setCentralWidget(self.widget)

    def openDialog(self):
        d = SecondDialog()
        d.exec_()

if __name__ == '__main__':
   app = QApplication(sys.argv)
   w = MyWindows()
   w.show()
   sys.exit(app.exec_())

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...