Hi to all,
this is a notice of what I tried and found about single or better, multipleselection, listwidget-s and listview-s used via hbqtui_:
1. Windows XP and XP with unchecked - "Use visual styles on windows and buttons" in widows "Performance options""
- all selections and unselections are displayed with appropriate colors: blue and white
2. Windows 7 and with Aero or Basic theme
- all selections and unselections are displayed with the white color. The selected items instead to be filled with a color, have only a rectangle border
3. Windows 7 with Classic theme or by unchecking the - "Use visual styles on windows and buttons" in widows "Performance options"
- all selections and unselections are displayed with appropriate colors: blue and white
Now, how make it work on Windows 7 and with Aero or Basic theme
By altering the Pritpals suggested code when filling the listwidget ther are 2 ways:
oDlg:listwidget13:setFocusPolicy( Qt_NoFocus ) // needed line that can be defined in Qt designer too and that permitt us to change the colors, without, nothing happends
FOR i=1 TO LEN(aParts3) // aPart3 is an array of text items
oItem := QListWidgetItem()
oItem:setText( aParts3[i] )
oDlg:listWidget13:addItem( oItem )
1. oDlg:listwidget13:connect( "itemClicked(QListWidgetItem*)", {|oItem| oItem:setBackground(QBrush(QColor(IF(oItem:isSelected(),Qt_darkCyan ,Qt_white)))),oDlg:listWidget13:show() })
NEXT
2. oDlg:listwidget13:connect( "itemClicked(QListWidgetItem*)", {|| oDlg:listwidget13:currentItem():setBackground(QBrush(QColor(IF(oDlg:listwidget13:currentItem():isSelected(),Qt_darkCyan ,Qt_white)))),oDlg:listWidget13:show() })
We achieve the switching o the 2 colors and the selection is now of another color instead of be white.
There are 2 consequence of this:
1. The selected buttons are no 3D like
2. XP with unchecked - "Use visual styles on windows and buttons" in widows "Performance options""
and Window 7 Classic users will see the selection as gray. No colors will be changed. That's because we turn of the focus policy. Now XP have its rules
So it is getting really difficult to make happy everyone.
By using qpalette(), setstylesheet() or else, under UI, we can't customize the selection rectangle as in common circumstances, because the Aero won't let, in any manner, alter some visual defaults.
I found a good number od articles about this Qt problem with Aero, the problem extends also on Windows 8 and to other UI objects, but no some final answer, just suggestions to try this or try that.
The interesting thing is that if we not use the UI, but we create the whole dialog with the elements by code in the prg, then the used visual style for the elements is the same as windows 7.
I dont know with what Qt designer saves the UI or how act hbqtui_ when reading it and generates the code, but maybe there is something that is missing in the formulation of listwigets and listviews.
This because the comboboxes in the UI through hbqtui_ , when we scrool the items, are of a right blue color, but the lists in listwidget and listview are not.
At this moment I will move-back to the classic dialog creation for all my dialogs that uses listview and listwidget and wait till something shows up.
Zoran