PDA

View Full Version : Need Qt Optimization for 32MB ram Machine



rajeshs
25th July 2007, 05:27
Hello All,

I am using QT 4.3 , My Application should be run on 32 mb ram machine, I am using ListWidget in my application , each time when i press up and down button i am giving scrolling of elements by using scrolltoitem() which in term takes items from QList as follows,

QList<QListWidgetItem*> listItem1=m_pListWidget->findItems(list.value(position),Qt::MatchExactly);

if(!listItem.isEmpty())
m_pListWidget->scrollToItem(listItem1.value(0),QAbstractItemView: :PositionAtTop);

Here m_pListWidget is QListWidget, list is QList which has whole data

Like this I have 4 ListWidgets While scrolling like this its taking more time,


Is there any option to optimize application by disabling unwanted options from qt Makefile or Configure file, Because my application should be run on 32 mb ram machine

jpn
25th July 2007, 20:46
For minimal memory consumption and better performance you should forget about QListWidget and go with QListView + efficiently written simple custom model.

rajeshs
26th July 2007, 04:27
hello sir,

Please give me idea about how to use qlistview and how to wrie custom modal,

jpn
26th July 2007, 09:42
You could try out with QStringListModel which is a simple wrapper model for QStringList. To get even more control, go with subclassing QAbstractListModel after reading model subclassing reference (http://doc.trolltech.com/4.3/model-view-model-subclassing.html).

rajeshs
27th July 2007, 04:34
Hello sir,

Please give som simple example how to use Listview,

jpn
27th July 2007, 05:56
Now that you're currently using QListWidget, does it contain anything else but strings? QStringListModel which is very easy to use:


#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStringList items = QStringList() << "1" << "2" << "3";
QListView* view = new QListView;
QStringListModel* model = new QStringListModel(items);
view->setModel(model);
view->show();
return a.exec();
}

Just be aware that QStringListModel is not able to store anything else but strings (Qt::DisplayRole & Qt::EditRole).

Also, get rid of managing several list of same data and finding items like that upon every key press.