View Full Version : How to Modify QListView item height?
blackfox
17th September 2008, 06:59
hello, all,
I want to modify QListView item height or spacing between items. How to modify it?
qstyle? I don't find the property... :o
santhoshv84
17th September 2008, 07:09
Hi,
QListView is derived class of QWidget.
So you can use setFixedHeight ( int h ) i think..
Thanks,
Santhosh
aamer4yu
17th September 2008, 07:12
How are you using QLIstView ?
If you are using model, you need to return size hint from the data() function of the model.
something like
if(role == Qt::sizeHintRole)
return QSize(width,height);
blackfox
17th September 2008, 07:39
I think this could only affects the total height of widget, not item height...
Hi,
QListView is derived class of QWidget.
So you can use setFixedHeight ( int h ) i think..
Thanks,
Santhosh
blackfox
17th September 2008, 07:55
Just new a QListView in an Object. I wonder why setSpacing(...) function doesn't work..
How are you using QLIstView ?
If you are using model, you need to return size hint from the data() function of the model.
something like
if(role == Qt::sizeHintRole)
return QSize(width,height);
aamer4yu
17th September 2008, 08:58
Can you show us some code of what u are doing ?
hard to say whats wrong without seeing more
monst
12th May 2012, 07:50
Try this in the last resort:
QListView listView;
listView->setStyleSheet("QListView::item { height: 100px; }");
tferreira
16th May 2012, 11:38
If you're using a delegate, try to override the sizeHint method.
Header:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
Source:
QSize MyDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
return(QSize(100, 50));
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.