"Current" item in QListView on Windows has a grey highlight until it is clicked on.



  • Hello everybody,

    I have a QListView of items with the single item selected from the start via

    QListView::setCurrentIndex(const QModelIndex &)

    When user clicks on an item in the list, it becomes "current",
    because the signal QListView::clicked is connected to the slot that calls the method above.

    The problem:

    When the list is opened for the first time, the "current" item is highlighted with the pale grey bar:

    https://drive.google.com/file/d/0B3VIzaAFexv9S1g1UEFEV28wQUk/view?usp=sharing

    When user clicks on an item in the list for the first time, it becomes highlighted with the blue bar. From that moment on, whatever current item is, the highlight is blue:

    https://drive.google.com/file/d/0B3VIzaAFexv9eFBPNlF4WXdacTA/view?usp=sharing

    Notes:

    • The problem affects the look of the list only. The item is selected correctly regardless of the colour of the highlight.

    • The appearance of the list relies on system defaults.

    • The problem happens on Windows 8.1 only. The same program behaves as expected on Ubuntu 14.04 (i.e. the current item has blue system highlight from the start).

    • I tried to fix the problem by emitting QListView::activated(index) or QListView::clicked(index) signals. It did not help.

    • Using Qt 5.5.1 MSVC-2012 32 bit

    Thank you in advance for any suggestions!

    Roni.


  • Lifetime Qt Champion

    Hi,

    Can you check whether it does the same thing if you first call setFocus on your QListView ? Also is the window containing the QListView active ? Or is another program having the main focus ?



  • Hi SGaist,

    QListView::setFocus(Qt::MouseFocusReason) solved the problem! Thank you very much!!!

    Roni.


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working, now please make the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.