The code of the paint function is this:
{
// evil trick: find out whether we are painted onto our listbox
bool in_list_box = listBox() && listBox()->viewport() == p->device();
QRect r
( 0,
0, listBox
()->width
(), listBox
()->height
( ) );
//p->drawText(r,Qt::AlignLeft, "new item", -1);
p->drawText(10,10,"new item", -1);
qDebug("Drawing text");
}
void MyLBItem::paint(QPainter *p)
{
// evil trick: find out whether we are painted onto our listbox
bool in_list_box = listBox() && listBox()->viewport() == p->device();
QRect r( 0, 0, listBox()->width(), listBox()->height( ) );
//p->drawText(r,Qt::AlignLeft, "new item", -1);
p->drawText(10,10,"new item", -1);
qDebug("Drawing text");
}
To copy to clipboard, switch view to plain text mode
main function is:
int main(int argc, char **argv)
{
QListBox lb;
MyLBItem lbiE(&lb);
lb.setGeometry(100,100,200,200);
lb.insertItem(&lbiE);
// lbiE.SetName("item 1");
a.setMainWidget(&lb);
lb.show();
// lb.repaint();
return a.exec();
}
int main(int argc, char **argv)
{
QApplication a(argc,argv);
QListBox lb;
MyLBItem lbiE(&lb);
lb.setGeometry(100,100,200,200);
lb.insertItem(&lbiE);
// lbiE.SetName("item 1");
a.setMainWidget(&lb);
lb.show();
// lb.repaint();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
when i run the app, the text doesn't show, nor the debug message. any clue?
Bookmarks