yuvaraj.yadav
5th May 2009, 17:59
Hi
I hope you people will encourage me...
Still I am reading the documents ... At same time trying with sample programs...
Already Wysto told me don't use the list view to add widgets.... I don't use here after...
Sorry , I am learning slowly....here i have been trying one small sample application
Nothing displaying the Tweets...I displayed tweets in listview with somebody help..
Here i am using the Event methods to get the current window position...and i assign the width to my tweet..
please see my code.
To display the tweet
QStandardItemModel * model = new QStandardItemModel(this);
for (int i = 0; i < 21; ++i)
{
QStandardItem * item = new QStandardItem;
model->appendRow(item);
}
ui->listView->setModel(model);
for (int i = 0; i < 21; ++i)
{ Tweet * t = new Tweet(this);
t->resize(ui->listView->size().width(), t->size().height());
qDebug("width:%d",ui->listView->size().width());
qDebug("Height:%d", t->size().height());
model->item(i)->setSizeHint(t->size());
ui->listView->setIndexWidget(model->item(i)->index(), t);
}
}
my event function
void MainWindow::resizeEvent( QResizeEvent *event )
{
emit resizeView( event->size().width(), event->oldSize().width() );
}
this one emit the resizeView and call the resizeData slot...
My slot code is
void MainWindow ::resizeData(int width, int oldWidth)
{
qDebug("current width:%d and old width : %d", width,oldWidth);
QSize itemSize;
Tweet *aTweet;
for ( int i = 0; i < 21; 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 resized my tweet width according to the window width....
If i try to modify the window window size, the window is crazed(closed)...
Please help me to solve this issue
I hope you people will encourage me...
Still I am reading the documents ... At same time trying with sample programs...
Already Wysto told me don't use the list view to add widgets.... I don't use here after...
Sorry , I am learning slowly....here i have been trying one small sample application
Nothing displaying the Tweets...I displayed tweets in listview with somebody help..
Here i am using the Event methods to get the current window position...and i assign the width to my tweet..
please see my code.
To display the tweet
QStandardItemModel * model = new QStandardItemModel(this);
for (int i = 0; i < 21; ++i)
{
QStandardItem * item = new QStandardItem;
model->appendRow(item);
}
ui->listView->setModel(model);
for (int i = 0; i < 21; ++i)
{ Tweet * t = new Tweet(this);
t->resize(ui->listView->size().width(), t->size().height());
qDebug("width:%d",ui->listView->size().width());
qDebug("Height:%d", t->size().height());
model->item(i)->setSizeHint(t->size());
ui->listView->setIndexWidget(model->item(i)->index(), t);
}
}
my event function
void MainWindow::resizeEvent( QResizeEvent *event )
{
emit resizeView( event->size().width(), event->oldSize().width() );
}
this one emit the resizeView and call the resizeData slot...
My slot code is
void MainWindow ::resizeData(int width, int oldWidth)
{
qDebug("current width:%d and old width : %d", width,oldWidth);
QSize itemSize;
Tweet *aTweet;
for ( int i = 0; i < 21; 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 resized my tweet width according to the window width....
If i try to modify the window window size, the window is crazed(closed)...
Please help me to solve this issue