Qt Forum

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

    Call for Presentations - Qt World Summit

    [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?

    Mobile and Embedded
    qlistwidget focus item selection qt5.2.1 linux
    2
    4
    4675
    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.
    • A
      Ajith_P_V last edited by Ajith_P_V

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • A
          Ajith_P_V @SGaist last edited by

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

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post