View Full Version : resize problem

4th May 2009, 16:29

i am facing resize problem...

My code is


QStandardItemModel * model = new QStandardItemModel(this);
for (int i = 0; i < 24; ++i)
QStandardItem * item = new QStandardItem;
for (int i = 0; i < 24; ++i)
Tweet * t = new Tweet();
t->resize(ui->listView->size().width(), 70);

ui->listView->setIndexWidget(model->item(i)->index(), t);
if ( i == 24- 1 ){
resizeData( ui->listView->width(), ui->listView->width() - 1 );

Here i calling the resizedata when i==24-1;

My resizeData code is

resizeData(int width, int oldWidth)

QSize itemSize;
Tweet *aTweet;
for ( int i = 0; i < 24; i++ ) {
aTweet = t;
aTweet->resize( width , aTweet->size().height() );
itemSize = model->item(i)->sizeHint();
itemSize.rwidth() += width - oldWidth;
itemSize.rheight() = aTweet->size().height();
model->item(i)->setSizeHint( itemSize );

here i am getting the listview current width and previous width ...

From there i calculated the new width...and i assigned to my items...

But this one is not displaying ...

I don't know whats problem with me ....

please help me


Yuvaraj R

4th May 2009, 16:56
What is the question?

4th May 2009, 18:13
My question is how do i display less amount of items(tweet) ,when i am minimizing the list view width

and while maximizing list view width ,it has to show more items(tweet)


Yuvaraj R

4th May 2009, 18:42
First of all, how do you expect anybody to know how your "Tweet" class behaves just by knowing what the class is called?

Second of all this is the next thread in series where you show no understanding of the model-view concept and despite being asked continuously if you are sure if you should use it and why you place widgets inside each index of the list you don't answer but instead post yet another thread related to an incorrect usage of the list view. What you are trying to do is expecting a coffee machine to bake cookies. Coffee machine is for making coffee, not for baking cookies. List view is not for placing widgets inside it, use QScrollArea instead for God's sake!