Python PyQt4:将QtMessageBox.information功能添加到自定义窗口
我需要的是非常相似的QtMessageBox.information方法,但我需要它形成我的自定义窗口 我需要一个有几个标签的窗口,一个QtTreeViewWidget,一个QButtonGroup…这个窗口将从主窗口调用。如果我们将实现被调用窗口的类调用为SelectionWindow,那么我需要的是:Python PyQt4:将QtMessageBox.information功能添加到自定义窗口,python,pyqt4,Python,Pyqt4,我需要的是非常相似的QtMessageBox.information方法,但我需要它形成我的自定义窗口 我需要一个有几个标签的窗口,一个QtTreeViewWidget,一个QButtonGroup…这个窗口将从主窗口调用。如果我们将实现被调用窗口的类调用为SelectionWindow,那么我需要的是: class MainWindow(QtGui.QMainWindow): ... def method2(self): selWin = SelectionWi
class MainWindow(QtGui.QMainWindow):
...
def method2(self):
selWin = SelectionWindow()
tempSelectionValue = selWin.getSelection()
# Blocked until return from getSelection
self.method1(tempSelectionValue)
...
class SelectionWindow(QtGui.QMainWindow):
...
def getSelection(self):
...
return selectedRow
...
方法GetSelectionWindow中的getSelection应弹出选择窗口,并在QTreeViewWidget中选择的返回行末尾。我希望主窗口保持阻塞状态,直到用户在选择窗口中选择一行并通过按钮确认。我希望你能理解我需要什么
我将感谢任何帮助
谢谢,
Tiho我会这样做:
- 带有按钮框的对话框窗口-> 连接到accept()和 拒绝()对话框本身的插槽
- 将对话框模态设置为类似于应用程序模态
- 调用对话框的exec_u3;()方法,使其保持阻塞状态,直到用户选择ok/cancel
- 在exec_389;()方法的执行终止后,您可以从对话框小部件中读取所需内容李>
class SelectionWindow(QtGui.QMainWindow):
...
def getSelection(self):
result = self.exec_()
if result:
# User clicked Ok - read currentRow
selectedRow = self.ui.myQtTreeViewWidget.currentIndex()
else:
# User clicked Cancel
selectedRow = None
return selectedRow
...
redShadow,非常感谢你的回答。最后,我做了一些与你的建议非常相似的事情。