[Qt-interest] QVBoxLayout with 100s of items is hanging

Qt Quest qt.quest at yahoo.com
Thu Nov 26 22:18:26 CET 2009


OK, I've changed the code to a list view and great performance!
Now in each line I show a checkbox and HTML text. I want the user to be able to check the checkbox and press the links in the HTML text.
I'm trying to use a delegate, but I have few problems:

1. The HTML links in the label are not selectable - the cursor does not change to a pointer, and no event is generated. This is true also for the checkbox.
2. paint() function of delegate is the only one called..

I'm using:
ui.list->setItemDelegate(new MyDelegate());
  
void MyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{ 
	QStyleOptionProgressBar progressBarOption;
QCheckBox *check = new QCheckBox();
check->setChecked(true);
check->render(painter , QPoint(0,0));
check->setMaximumSize(QSize(14,14));
QLabel *label = new QLabel();
label->setText("this <a href=\"b\">is a <b>test</b></a>");
label->render(painter , QPoint(14,0));
}
Thank you!




________________________________
From: Sean Harmer <sean.harmer at maps-technology.com>
To: qt-interest at trolltech.com
Sent: Thu, November 26, 2009 2:43:32 PM
Subject: Re: [Qt-interest] QVBoxLayout with 100s of items is hanging

Hi,

On Thursday 26 November 2009 12:28:42 Qt Quest wrote:
> One more thing that I want to note is that on the screen only about 30
>  lines are being shown in the scrollable layout. Maybe it is possible to
>  defer the computations until the items are actually shown when the layout
>  is scrolled down?

As I suggested earlier if you use the model/view approach you will get this 
for free. Only those items in the view will be queried by the view for their 
actual data.

> Maybe it is possible to hasten the display of the layout using fixed sizes?

QTreeView::setUniroformRowHeights( true ) will do this optimisation for you. 

> Is this slow performance the destiny of every application with that much of
>  GUI controls? Thank you!

Having 1300 rows of widgets is really pushing things too far. Much better to 
have one widget designed to show that much data efficiently.

Just try it. Writing a simple table model is really not that hard to do.

You can always come back to the list with questions if you get stuck writing 
the model.

Sean
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091126/d201972c/attachment.html 


More information about the Qt-interest-old mailing list