Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    5
    1347
    Loading More Posts
    • 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
      Leon last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        You might try via the selectionModel().

        1 Reply Last reply Reply Quote 0
        • L
          Leon last edited by

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

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

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

            1 Reply Last reply Reply Quote 0
            • L
              Leon last edited by

              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 Reply Quote 0
              • First post
                Last post