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. [SOLVED] How to select item 3 of listwidget in 1 line?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to select item 3 of listwidget in 1 line?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k Views 1 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.
  • L Offline
    L Offline
    Leon
    wrote on 7 Sept 2012, 20:30 last edited by
    #1

    i just want to select item 3 of listwidget and it seems that
    @ui->listwidget->setCurrentItem(3);@

    won't work.
    I know a way to do it if i create a list of the items but it is about in 6 lines just to select an item..

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 7 Sept 2012, 20:33 last edited by
      #2

      You might try via the selectionModel().

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on 7 Sept 2012, 20:43 last edited by
        #3

        could you please be a little more detailed? at list one link to know where to look up...?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 7 Sept 2012, 20:45 last edited by
          #4

          Check [[doc:QAbstractItemModel]] for the selectionModel() method, and [[doc:QItemSelectionModel]] for the documentation of the selection model itself.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on 15 Sept 2012, 09:05 last edited by
            #5

            Well i prefered doing it this way as 1 row has 1 item:
            @
            ui->listWidget_2->setFocus();
            ui->listWidget_2->setCurrentRow(2);@

            :)

            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