<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Le 20/09/10 10:07, Cyril Giraudon a écrit :
<blockquote cite="mid:4C971642.3040102@free.fr" type="cite"> Hello,
<br>
<br>
I am a PyQt newbye and I wanted to do some tests with QToolBar in a
QDialog (Seems multiple QMainWindow use is not recommanded in a
QApplication), so I started coding a simple example (reported below).
<br>
<br>
The code seems correct but it terminates with a segmentation fault when
the QUIT button is pressed :
<br>
<br>
"""""""""""""""""""""""""""""""""""""
<br>
(sandbox)cyril@CGN-L: pyqt$ python example.py
<br>
Qt version : 4.6.2
<br>
PyQt version : 4.7.2
<br>
Erreur de segmentation
<br>
"""""""""""""""""""""""""""""""""""""
<br>
<br>
I don't understand what happens.
<br>
Is there any explanation ?
<br>
<br>
Thanks a lot,
<br>
<br>
Cyril.
<br>
<br>
<br>
"""""""""""""""""""""""""""""""""
<br>
example.py source code
<br>
"""""""""""""""""""""""""""""""""
<br>
# -*- coding: utf8 -*-
<br>
<br>
import sys
<br>
<br>
from PyQt4.QtCore import SIGNAL, SLOT, QT_VERSION_STR, PYQT_VERSION_STR
<br>
from PyQt4.QtGui import (QApplication, QDialog, QVBoxLayout,
<br>
QToolBar, QAction, QLabel)
<br>
<br>
if __name__=='__main__':
<br>
print "Qt version : ", QT_VERSION_STR
<br>
print "PyQt version : ", PYQT_VERSION_STR
<br>
<br>
app = QApplication(sys.argv)
<br>
<br>
dialog = QDialog()
<br>
dialog.setWindowTitle(u"Bye bye")
<br>
<br>
layout = QVBoxLayout(dialog)
<br>
<br>
toolbar = QToolBar()
<br>
<br>
label = QLabel("Hello World!")
<br>
def say_bye():
<br>
label.setText("Bye Bye")
<br>
bye_action = QAction("Bye bye", dialog, triggered=say_bye)
<br>
toolbar.addAction(bye_action)
<br>
<br>
quit_action = QAction("Quit", dialog)
<br>
dialog.connect(quit_action, SIGNAL("triggered()"),
<br>
app, SLOT("quit()"));
<br>
toolbar.addAction(quit_action)
<br>
<br>
layout.addWidget(toolbar)
<br>
layout.addWidget(label)
<br>
<br>
dialog.show()
<br>
app.exec_()
<br>
"""""""""""""""""""""""""""""""""""""""""
<br>
_______________________________________________
<br>
PyQt mailing list <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>
<br>
<br>
</blockquote>
Salut,<br>
<br>
Change these lines:<br>
<br>
bye_action = QAction("Bye bye", dialog)<br>
bye_action.triggered.connect(say_bye)<br>
toolbar.addAction(bye_action)<br>
<br>
quit_action = QAction("Quit", dialog)<br>
quit_action.triggered.connect(quit)<br>
toolbar.addAction(quit_action)<br>
<br>
and this one:<br>
<br>
sys.exit(app.exec_()) <br>
<br>
Cheers<br>
<br>
<div class="moz-signature">-- <br>
Vincent V.V.<br>
<a href="https://launchpad.net/oqapy">Oqapy</a></div>
</body>
</html>