Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved]How to focus on the last item of the and then come to the top item one by on using TAB key and UP-ARROW key?
Forum Updated to NodeBB v4.3 + New Features

[Solved]How to focus on the last item of the and then come to the top item one by on using TAB key and UP-ARROW key?

Scheduled Pinned Locked Moved Mobile and Embedded
qlistwidgetfocusitemselectionqt5.2.1linux
4 Posts 2 Posters 5.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.
  • A Offline
    A Offline
    Ajith_P_V
    wrote on last edited by Ajith_P_V
    #1

    Hi all,
    I have a small application in which, I have a QListWidget which basically list of some QString values.
    Now, I have only a TAB key for focusing into the QListWidget and then I have UP-ARROW key for navigation (focusing from one item to another) inside QListWidget .
    By default, the focus comes to the top item of the QListWidget hence, UP-ARROW key will not help me to go to other below items for selecting. So, I would like to know, how to focus on the last item while opening? Also, how to start from the last focused item to come to the top item (or any item in between) by pressing the UP_ARROW.

    I tried the following but, it kept focusing on the last item and not coming to the top items, when I use UP-ARROW:

    • QListWidget->item((QStringList.size()-1))->setSelected(true);

    Any help would be greatly appreciated.

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

      Hi,

      setCurrentRow should do what you want. For the selection part, did you enable multiple selection ?

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

      A 2 Replies Last reply
      1
      • SGaistS SGaist

        Hi,

        setCurrentRow should do what you want. For the selection part, did you enable multiple selection ?

        A Offline
        A Offline
        Ajith_P_V
        wrote on last edited by
        #3

        @SGaist Thank you for your support. I will test setCurrentRow along with setFocus to focus on the last row item of the listWidget.
        For the selection part, I need only single selection but it has to move from bottom to up instead of default top to bottom movement.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          setCurrentRow should do what you want. For the selection part, did you enable multiple selection ?

          A Offline
          A Offline
          Ajith_P_V
          wrote on last edited by
          #4

          @SGaist Thank you dude, setCurrentRow is what I want!

          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