我一直在关注本教程:https://www.blog.pythonlibrary.org/2013/04/16/pyside-standard-dialogs-and-message-boxes/,以便在单击对话框后让我的某个按钮显示通知消息框。问题是代码根本不显示对话框。这是我的代码,包括我到目前为止所尝试的内容以及堆栈跟踪。
# parsing Information Message Dialog
def data_parsed_notification(self):
"""
Show the information message
"""
QtGui.QMessageBox.information(self, "Information", "Data Has Been Parsed!")
# Data Parsing Functions!!!
# Canonical Addresses button function
def select_canonical_data(self):
os.system('CanonicalAddressesParser.py')
self.generate_canonical_report.setEnabled(True)
self.canonicalAddressesButton.clicked.connect(self.data_parsed_notification())
堆栈跟踪
QtGui.QMessageBox.information(self, "Information", "Data Has Been Parsed!")
AttributeError: 'module' object has no attribute 'QMessageBox'
目前正在编码
# Data Parsed Dialog Box
def data_parsed_notification(self):
msgBox = QtWidgets.QMessageBox(self)
msgBox.setWindowTitle('Information')
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setText('Data Has Been Parsed!')
msgBox.show()
# Canonical Addresses button function
def select_canonical_data(self):
os.system('CanonicalAddressesParser.py')
self.generate_canonical_report.setEnabled(True)
self.canonicalAddressesButton.clicked.connect(self.data_parsed_notification())
Stack Trace
TypeError: arguments did not match any overloaded call:
QMessageBox(QWidget parent=None): argument 1 has unexpected type 'Ui_MainWindow'
QMessageBox(QMessageBox.Icon, str, str, QMessageBox.StandardButtons buttons=QMessageBox.NoButton, QWidget parent=None, Qt.WindowFlags flags=Qt.Dialog|Qt.MSWindowsFixedSizeDialogHint): argument 1 has unexpected type 'Ui_MainWindow'
答案 0 :(得分:0)
尝试以下代码,它将适合您。
ambarish@axiom:~/cpp$ g++ shiftOper.cpp
shiftOper.cpp:7:1: warning: "LINUX_VERSION_CODE" redefined
shiftOper.cpp:6:1: warning: this is the location of the previous definition
#define LINUX_VERSION_CODE 265216
#define LINUX_VERSION_CODE 666
int main ()
{
}