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. Setting selection in QListView widget
Forum Updated to NodeBB v4.3 + New Features

Setting selection in QListView widget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.8k 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.
  • R Offline
    R Offline
    RogerCleg
    wrote on last edited by
    #1

    I'm a new Qt developer. Can anyone tell me how I would force a selection in a QListView widget?

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi there,
      Not really sure what you mean. What do you want to force? Or do you just want a line selected at all times? Maybe a small picture with it to show what you need.
      Greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        Welcome to the Forum,

        I agree that you can be a bit more clear about your requirements. An image will be perfect as discussed above. From my assumptions of force selection in a QListView, i think you want

        a. Forcefully select an particular index/row on start up
        ans. You can get the QModelIndex for the particular row and use "setSelectedIndex(index)":http://doc.qt.digia.com/qt/qabstractitemview.html#setCurrentIndex funtion and through stylesheets you can change the border-color or width.

        or

        b. To set the focus on QListView.
        ans. check "setFocus()":http://doc.qt.digia.com/qt/qwidget.html#setFocus

        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