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
QtWS25 Last Chance

QListWidgetItem activate first item

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.4k 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 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 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
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on 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 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
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 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 last edited by
              #6

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

              Thanks for your help and patience!!

              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