-1
我畫了一個簡單的GUI(基本上,一個窗體中的按鈕 - 實際上,我注意到這發生在一個更復雜的應用程序中,所以我將它簡化爲觸發問題的最小情況),使用Qt設計師,並寫了這個Python代碼:QMessageBox導致段錯誤
from PyQt4 import QtCore, QtGui, Qt
from ui_main import Ui_MainWindow
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.process = QtCore.QProcess()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
@QtCore.pyqtSignature("")
def on_pushButtonTest_clicked(self, checked=False):
QtGui.QMessageBox.information(self,'test','test')
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())
然後,當我點擊pushButtonTest,我得到一個段錯誤。 gdb
下運行我得到這個回溯:
#0 0x00007ffff7ade785 in do_warn() from /usr/lib/libpython2.7.so.1.0
#1 0x00007ffff7adec4c in PyErr_WarnEx() from /usr/lib/libpython2.7.so.1.0
#2 0x00007fffe563f3b5 in ??() from /usr/lib/python2.7/site-packages/gobject/_gobject.so
#3 0x00007fffe5b0ca00 in g_logv() from /usr/lib/libglib-2.0.so.0
#4 0x00007fffe5b0cbf2 in g_log() from /usr/lib/libglib-2.0.so.0
#5 0x00007fffe4c67a52 in ??() from /usr/lib/libgtk-x11-2.0.so.0
#6 0x00007fffe4c69419 in ??() from /usr/lib/libgtk-x11-2.0.so.0
#7 0x00007fffe4c69891 in ??() from /usr/lib/libgtk-x11-2.0.so.0
#8 0x00007fffe4c6a332 in gtk_icon_theme_lookup_icon() from /usr/lib/libgtk-x11-2.0.so.0
#9 0x00007fffe4c6ae14 in gtk_icon_theme_load_icon() from /usr/lib/libgtk-x11-2.0.so.0
#10 0x00007fffe4c66311 in gtk_icon_set_render_icon() from /usr/lib/libgtk-x11-2.0.so.0
#11 0x00007fffd980e469 in ??() from /usr/lib/libQtGui.so.4
#12 0x00007fffd980d279 in QGtkStyle::standardIconImplementation(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const() from /usr/lib/libQtGui.so.4
#13 0x00007fffd9af690f in ??() from /usr/lib/libQtGui.so.4
#14 0x00007fffdacc15b7 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const() from /usr/lib/libQtCore.so.4
#15 0x00007fffdacc398c in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument)() from /usr/lib/libQtCore.so.4
#16 0x00007fffd978450d in QStyle::standardIcon(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const() from /usr/lib/libQtGui.so.4
#17 0x00007fffd996575f in ??() from /usr/lib/libQtGui.so.4
#18 0x00007fffd9965847 in QMessageBox::setIcon(QMessageBox::Icon)() from /usr/lib/libQtGui.so.4
#19 0x00007fffd9966cd3 in QMessageBox::QMessageBox(QMessageBox::Icon, QString const&, QString const&, QFlags<QMessageBox::StandardButton>, QWidget*, QFlags<Qt::WindowType>)() from /usr/lib/libQtGui.so.4
#20 0x00007fffd9966f03 in ??() from /usr/lib/libQtGui.so.4
#21 0x00007fffd996710f in QMessageBox::information(QWidget*, QString const&, QString const&, QFlags<QMessageBox::StandardButton>, QMessageBox::StandardButton)() from /usr/lib/libQtGui.so.4
#22 0x00007fffda2dc8a6 in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtGui.so
#23 0x00007ffff7afe05a in PyEval_EvalFrameEx() from /usr/lib/libpython2.7.so.1.0
#24 0x00007ffff7afeedd in PyEval_EvalCodeEx() from /usr/lib/libpython2.7.so.1.0
#25 0x00007ffff7a8f536 in function_call() from /usr/lib/libpython2.7.so.1.0
#26 0x00007ffff7a6b8be in PyObject_Call() from /usr/lib/libpython2.7.so.1.0
#27 0x00007ffff7a79e78 in instancemethod_call() from /usr/lib/libpython2.7.so.1.0
#28 0x00007ffff7a6b8be in PyObject_Call() from /usr/lib/libpython2.7.so.1.0
#29 0x00007ffff7af8577 in PyEval_CallObjectWithKeywords() from /usr/lib/libpython2.7.so.1.0
#30 0x00007fffda9375b0 in ??() from /usr/lib/python2.7/site-packages/sip.so
#31 0x00007fffdb208c96 in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtCore.so
#32 0x00007fffdb208fe0 in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtCore.so
#33 0x00007fffdb209061 in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtCore.so
#34 0x00007fffdacced53 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**)() from /usr/lib/libQtCore.so.4
#35 0x00007fffd9af7512 in QAbstractButton::clicked(bool)() from /usr/lib/libQtGui.so.4
#36 0x00007fffd984be7e in ??() from /usr/lib/libQtGui.so.4
#37 0x00007fffd984c6b0 in ??() from /usr/lib/libQtGui.so.4
#38 0x00007fffd984c91c in QAbstractButton::mouseReleaseEvent(QMouseEvent*)() from /usr/lib/libQtGui.so.4
#39 0x00007fffda47161b in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtGui.so
#40 0x00007fffd94e1a49 in QWidget::event(QEvent*)() from /usr/lib/libQtGui.so.4
#41 0x00007fffda471bbb in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtGui.so
#42 0x00007fffd949218c in QApplicationPrivate::notify_helper(QObject*, QEvent*)() from /usr/lib/libQtGui.so.4
#43 0x00007fffd9496e6b in QApplication::notify(QObject*, QEvent*)() from /usr/lib/libQtGui.so.4
#44 0x00007fffda48bcde in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtGui.so
#45 0x00007fffdacb96ae in QCoreApplication::notifyInternal(QObject*, QEvent*)() from /usr/lib/libQtCore.so.4
#46 0x00007fffd9492fcb in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)() from /usr/lib/libQtGui.so.4
#47 0x00007fffd950dad4 in ??() from /usr/lib/libQtGui.so.4
#48 0x00007fffd950c861 in QApplication::x11ProcessEvent(_XEvent*)() from /usr/lib/libQtGui.so.4
#49 0x00007fffd9532a22 in ??() from /usr/lib/libQtGui.so.4
#50 0x00007fffe5b05845 in g_main_context_dispatch() from /usr/lib/libglib-2.0.so.0
#51 0x00007fffe5b05b78 in ??() from /usr/lib/libglib-2.0.so.0
#52 0x00007fffe5b05c34 in g_main_context_iteration() from /usr/lib/libglib-2.0.so.0
#53 0x00007fffdace7b66 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)() from /usr/lib/libQtCore.so.4
#54 0x00007fffd953269e in ??() from /usr/lib/libQtGui.so.4
#55 0x00007fffdacb83ff in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)() from /usr/lib/libQtCore.so.4
#56 0x00007fffdacb8688 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)() from /usr/lib/libQtCore.so.4
#57 0x00007fffdacbd328 in QCoreApplication::exec()() from /usr/lib/libQtCore.so.4
#58 0x00007fffda48a91b in ??() from /usr/lib/python2.7/site-packages/PyQt4/QtGui.so
#59 0x00007ffff7afe05a in PyEval_EvalFrameEx() from /usr/lib/libpython2.7.so.1.0
#60 0x00007ffff7afeedd in PyEval_EvalCodeEx() from /usr/lib/libpython2.7.so.1.0
#61 0x00007ffff7afefb2 in PyEval_EvalCode() from /usr/lib/libpython2.7.so.1.0
#62 0x00007ffff7b17eea in run_mod() from /usr/lib/libpython2.7.so.1.0
#63 0x00007ffff7b18ce2 in PyRun_FileExFlags() from /usr/lib/libpython2.7.so.1.0
#64 0x00007ffff7b196fb in PyRun_SimpleFileExFlags() from /usr/lib/libpython2.7.so.1.0
#65 0x00007ffff7b2a9f2 in Py_Main() from /usr/lib/libpython2.7.so.1.0
#66 0x00007ffff7480725 in __libc_start_main() from /usr/lib/libc.so.6
#67 0x0000000000400741 in _start()
爲什麼我會得到這個段錯誤,我該如何解決這一問題?
我在Arch Linux上使用Qt 4.8.4和Python 2.7。