Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2008
QPainter - Cannot paint on null pixmap


Message 1 in thread

Hi,

I've got a problem and I cannot figure out where it comes from. So,
here's what I have:

A QMainWindow including a QTableWidget and a customized QWidget. 
This QWidget is included for some really simple painting activities.
The QTableWidget has 8 columns. The content of the first column 
will be extracted and drawn into the QWidget. The content is a text 
string and shall be displayed as large as possible but at a max of 
21 pixels. If the string is too long to fit into the QWidget, the 
font size of 21 pixels is decreased by 1 pixel as long as either 
the string fits into the QWidget properly or the font size reaches 
a minimum value of 8 pixels. If so, the string is shortened and the 
procedure is repeated again by a font size of 21 pixels. Additionally 
the QTableWidget has implemented the QWidget::resizeEvent to resize 
the colums and rows to their contents by using QTableView::resizeColumnsToContents 
and QTableView::resizeRowsToContents. (This seems to be the bad part 
in my opinion.)

This all works very fine (!) until the string to be drawn gets about 
5300 characters. Then I got the errors:

QPainter::begin: Cannot paint on a null pixmap
QPainter::end: Painter not active, aborted
X Error: BadAlloc (insufficient resources for operation) 11
  Major opcode: 53 (X_CreatePixmap)
  Resource id:  0x4010028
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Extension:    153 (RENDER)
  Minor opcode: 4 (RenderCreatePicture)
  Resource id:  0x4010028
X Error: RenderBadPicture (invalid Picture parameter) 177
  Extension:    153 (RENDER)
  Minor opcode: 7 (RenderFreePicture)
  Resource id:  0x4010029
X Error: BadPixmap (invalid Pixmap parameter) 4
  Major opcode: 54 (X_FreePixmap)
  Resource id:  0x4010028

If I resize the QMainWindow's nothing happens but if I resize the 
QTableWidget's first column (Will the resizeEvent be called?) those 
errors appear. A bit curios about this: Sometimes only the first 
to lines appear, sometimes all the erros come accross.

Hope anyone could help.

Thanks in advance,
Marcel






--
 [ signature omitted ]