Bonjour,
je souhaite créer une boîte de dialogue contenant un QwebView dont la largeur s'ajustera aux dimensions de la boîte de dialogue.
Mon code ci-dessous ne marche pas : quand on redimensionne la boîte, une partie du QwebView disparaît.
Je suis preneur d'une méthode purement de programmation, mais je préfèrerais savoir comment faire avec Qt Designer.
Le code Python : dial_VisuHTML.py
Le code ui pour Qt Designer : dial_VisuHTML.ui
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Documents and Settings\Christophe\Mes documents\2,pyBaNaMa\DebuterAvecPythonEtPyQT\CodesProjets\04-Proj4_MiniEditHTML\05-TestWebKit\dial_VisuHTML.ui ' # # Created: Thu Aug 07 18:41:06 2008 # by: PyQt4 UI code generator 4.4.2 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_dial_VisuHTML(object): def setupUi(self, dial_VisuHTML): dial_VisuHTML.setObjectName("dial_VisuHTML") dial_VisuHTML.resize(498,487) self.verticalLayoutWidget = QtGui.QWidget(dial_VisuHTML) self.verticalLayoutWidget.setGeometry(QtCore.QRect(9,9,481,461)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setSizeConstraint(QtGui.QLayout.SetNoConstraint) self.verticalLayout.setObjectName("verticalLayout") self.webView = QtWebKit.QWebView(self.verticalLayoutWidget) self.webView.setUrl(QtCore.QUrl("about:blank")) self.webView.setObjectName("webView") self.verticalLayout.addWidget(self.webView) self.retranslateUi(dial_VisuHTML) QtCore.QMetaObject.connectSlotsByName(dial_VisuHTML) def retranslateUi(self, dial_VisuHTML): dial_VisuHTML.setWindowTitle(QtGui.QApplication.translate("dial_VisuHTML", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) from PyQt4 import QtWebKit if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) dial_VisuHTML = QtGui.QDialog() ui = Ui_dial_VisuHTML() ui.setupUi(dial_VisuHTML) dial_VisuHTML.show() sys.exit(app.exec_())
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 <ui version="4.0" > <class>dial_VisuHTML</class> <widget class="QDialog" name="dial_VisuHTML" > <property name="geometry" > <rect> <x>0</x> <y>0</y> <width>498</width> <height>487</height> </rect> </property> <property name="windowTitle" > <string>Dialog</string> </property> <widget class="QWidget" name="verticalLayoutWidget" > <property name="geometry" > <rect> <x>9</x> <y>9</y> <width>481</width> <height>461</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout" > <property name="spacing" > <number>5</number> </property> <property name="sizeConstraint" > <enum>QLayout::SetDefaultConstraint</enum> </property> <property name="margin" > <number>5</number> </property> <item> <widget class="QWebView" name="webView" > <property name="url" > <url> <string>about:blank</string> </url> </property> </widget> </item> </layout> </widget> </widget> <customwidgets> <customwidget> <class>QWebView</class> <extends>QWidget</extends> <header>QtWebKit/QWebView</header> </customwidget> </customwidgets> <resources/> <connections/> </ui>
Partager