Page 1 of 1

QTreeWidgetItem Icon

Posted: Fri Sep 03, 2010 4:55 am
by Rathinagiri
Hi

I invite your kind attention to Line no. 655 of QTreeWidgetItem.cpp file.

Code: Select all

655 HB_FUNC( QT_QTREEWIDGETITEM_SETICON )
656 	{
657 	QTreeWidgetItem * p = hbqt_par_QTreeWidgetItem( 1 );
658 	if( p )
659 	( p )->setIcon( hb_parni( 2 ), QIcon( hbqt_par_QString( 3 ) ) );
660 	else
661 	{
662 	HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_QTREEWIDGETITEM_SETICON FP=( p )->setIcon( hb_parni( 2 ), QIcon( hbqt_par_QString( 3 ) ) ); p is NULL" ) );
663 	}
664 	} 
It deals with setting an icon for tree items. As of now, the third parameter for this function should be a string (may be icon filename from disk or resource). In the case of tree item, we can have item states (normal and selected) (for example a closed book icon for normal state and an open book icon for selected state).

For this I have created a Quick Icon with two Pixmaps using addPixmap method.

Since the third parameter here is not QIcon but a string, I could not set the icon for treewidgetitem. I understand this is used for simplicity.

Now, can we have another function/method to pass the third parameter as QIcon itself?

Re: QTreeWidgetItem Icon

Posted: Sat Sep 04, 2010 12:12 am
by bedipritpal
rathinagiri wrote:Hi

I invite your kind attention to Line no. 655 of QTreeWidgetItem.cpp file.

It deals with setting an icon for tree items. As of now, the third parameter for this function should be a string (may be icon filename from disk or resource). In the case of tree item, we can have item states (normal and selected) (for example a closed book icon for normal state and an open book icon for selected state).

For this I have created a Quick Icon with two Pixmaps using addPixmap method.

Since the third parameter here is not QIcon but a string, I could not set the icon for treewidgetitem. I understand this is used for simplicity.

Now, can we have another function/method to pass the third parameter as QIcon itself?

Yep, thi slimitation is self induced one since very begining of hbQT evolution when I thought it is easier to send image by name rather than constructing icon before passing to another method. Your explanation above is valid and I am looking into how dynamically it can be resolved. A lot of code has already been developed around it, so I have to be extremely careful.

BTW: nothing personal, but can you change your Avatar to a simple image than blinking one. It just disturbs and probably need more patient to stay on the page it is depicted.