Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "Current" item in QListView on Windows has a grey highlight until it is clicked on.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roni219
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roni219
        wrote on last edited by
        #3

        Hi SGaist,

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

        Roni.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved