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. QListWidgetItem activate first item
Forum Updated to NodeBB v4.3 + New Features

QListWidgetItem activate first item

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.5k Views
  • 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.
  • U Offline
    U Offline
    Ugiat
    wrote on 29 Jun 2017, 10:34 last edited by
    #1

    Hi,

    I am stuck in the activation of the first item from a QListWidget. I am using setCurrentRow method which already works for the rest of the items but not for the first one. Debugging I can know that the first item is already selected and activated but in the list widget is not highlighted in blue as it does when the item is activated.

    Thank you in advance

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Fuel
      wrote on 29 Jun 2017, 10:40 last edited by
      #2

      You could, when you open the Window, select it manually with this

      Return the first Element of that Widget as Pointer with QListWidget->takeItem() and set it to selected.

      1 Reply Last reply
      1
      • V Offline
        V Offline
        VRonin
        wrote on 29 Jun 2017, 12:11 last edited by
        #3

        listWidget->selectionModel()->setCurrentIndex(listWidget->model()->index(0,0));

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • U Offline
          U Offline
          Ugiat
          wrote on 29 Jun 2017, 13:51 last edited by
          #4

          Thanks for your answers. Both solutions are working for the rest of the items but not for the first one... :(

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRonin
            wrote on 29 Jun 2017, 13:59 last edited by
            #5

            Could you show your code?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • U Offline
              U Offline
              Ugiat
              wrote on 3 Jul 2017, 08:47 last edited by
              #6

              I solved the problem. It was a bug...

              Thanks for your help and patience!!

              1 Reply Last reply
              0

              5/6

              29 Jun 2017, 13:59

              • Login

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