[Qt-interest] Can't change the Icon size in the HeadView of QTableView!

bob bob.li at i-soft.com.cn
Thu Aug 26 03:28:22 CEST 2010


Andre Somers 写道:
>   Op 25-8-2010 8:24, bob schreef:
>   
>> Hi, All,
>>
>> When i use QTableView, find can't change the icon size in the HeadView
>> of it. The core part of code as follow:
>>
>> QTableView *pv = new QTableView();
>> QStandardItemModel* pm = new QStandardItemModel();
>> QStandardItem* pi = new QStandardItem(QIcon("./channel.png"), "hello");
>> //the size of png file is 128*128
>> pm->setHorizontalHeaderItem(0, pi);
>> pv->setModel(pm);
>> pv->setGeometry(100, 50, 400, 200);
>> pv->setParent(this);
>> QHeaderView *ph = pv->horizontalHeader();
>> ph->setFixedHeight(80);
>> ph->setIconSize(QSize(40,40));
>>
>> I try to change the size of ph->setIconSize(QSize(40,40)); ,but the size
>> of icon don't do any change, why?
>>
>> BTW:the version is qt-everywhere-opensource-src 4.6.2
>>
>> Best Regards
>>     
> Please take a look at the documentation for QHeaderView. In the last 
> section of the detailed description, you find the header "Appearance". 
> It is detailed that:
> 1) delegates are not used, even though there is a setDelegate method.
> 2) only some of the item roles are used; sizeHint not being one of them.
>
> It looks like the only way is to subclass QHeaderView, and reimplement 
> the sizeHint and paint methods.
>   
I will try it.

Anyway, i think this is a shortcoming of QHeadView.

Thanks very much!

Bob
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   




More information about the Qt-interest-old mailing list