Hi Everybody,
I want to build multiple documents report using toolbox. Two pages is an option get a start. Formatting is ok, and can be worked latter.
I tried using QTextDocument in Html, and alternatively QPainter.
Of course, to make a test and keep things simple, I just ask in Qt to show the report title displayed on top of the document.
Here is the function for the toolbox main frame:
def toolbox_frame(self,MainWindow):
self.toolBox = QtGui.QToolBox(self.centralwidget)
self.toolBox.setGeometry(QtCore.QRect(10, 20, 471, 201))
self.toolbox_page1()
self.toolBox.addItem(self.page1, "")
self.toolBox.setItemText(self.toolBox.indexOf(self.page1), QtGui.QApplication.translate("MainWindow", "Page 1", None, QtGui.QApplication.UnicodeUTF8))
self.toolbox_page2()
self.toolBox.addItem(self.page2, "")
self.toolBox.setItemText(self.toolBox.indexOf(self.page2), QtGui.QApplication.translate("MainWindow", "Page 2", None, QtGui.QApplication.UnicodeUTF8))
... the function that holds the first page using QTextDocument with Html:
def toolbox_page1(self):
self.page1 = QtGui.QWidget()
self.page1.setGeometry(QtCore.QRect(0, 0, 471, 145))
html = u""
html += (" <p><font color=red><b>Title - Build "
"a Report : page 1.</b></font>")
document = QtGui.QTextDocument(self.page1)
document.setHtml(html)
and here the function using QPainter:
def toolbox_page2(self):
self.page2 = QtGui.QWidget()
self.page2.setGeometry(QtCore.QRect(0, 0, 471, 145))
sansFont = QtGui.QFont("Helvetica", 10)
painter = QtGui.QPainter(self.page2)
painter.setFont(sansFont)
painter.setPen(QtGui.QColor(168, 34, 3))
x=50
y=50
painter.drawText(x, y, "Title - Build a Report : page 2")
The problem is, that it just displays the toolbox with the page 1 and page 2, but not the title for both report inside the page 1 and page 2.
What is missing here?
All comments and suggestions are highly appreciated.