QTreeWidgetItem Icon

Moderator: Rathinagiri

Post Reply
User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 141 times
Been thanked: 131 times
Contact:

QTreeWidgetItem Icon

Post by Rathinagiri » Fri Sep 03, 2010 4:55 am

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?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
bedipritpal
Posts: 122
Joined: Thu Sep 02, 2010 10:47 pm

Post by bedipritpal » Sat Sep 04, 2010 12:12 am

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.
enjoy hbIDEing... Pritpal Bedi

Post Reply