If I run the following program, and scroll all the way down to the bottom of the window, I get a bunch of XErrors, like so:<br><br>X Error: BadAlloc (insufficient resources for operation) 11<br> Major opcode: 53 (X_CreatePixmap)<br>
Resource id: 0x8a<br>X Error: BadDrawable (invalid Pixmap or Window parameter) 9<br> Extension: 152 (RENDER)<br> Minor opcode: 4 (RenderCreatePicture)<br> Resource id: 0x460042e<br>X Error: RenderBadPicture (invalid Picture parameter) 169<br>
Extension: 152 (RENDER)<br> Minor opcode: 7 (RenderFreePicture)<br> Resource id: 0x460042f<br><br>I'm not sure if this is a qt bug, a pyqt bug, or what. Any suggestions would be appreciated.<br><br>-----------<br>
<br><br>import sys<br><br>from PyQt4.QtGui import *<br>from PyQt4.QtCore import *<br><br>app = QApplication(sys.argv)<br>main_window = QMainWindow()<br><br># Create a column of many QTextEdits in a QScrollArea<br>scroll_area = QScrollArea()<br>
column = QGroupBox()<br>column.setLayout(QVBoxLayout())<br>text_edits = []<br>for i in range(40):<br> # Add a lot of text to each QTextEdit<br> text_edit = QTextEdit("Testing " * 1000)<br> column.layout().addWidget(text_edit)<br>
text_edits.append(text_edit) <br> <br>main_window.setCentralWidget(scroll_area)<br><br>scroll_area.setWidget(column)<br>scroll_area.setWidgetResizable(True)<br><br>main_window.resize(600,300)<br><br># Resize each QTextEdit so that it displays all of its text without <br>
# needing scrollbars<br>for text_edit in text_edits: <br> fm = QFontMetrics(text_edit.font())<br> bounding_rect = QRect(0,0, text_edit.width(), 0)<br> bounding_rect = fm.boundingRect(bounding_rect, Qt.TextWrapAnywhere, <br>
text_edit.toPlainText())<br> text_edit.setFixedHeight(bounding_rect.height())<br><br>main_window.show()<br>app.exec_()