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. How to select row in QListView of QFileSystemModel ?
Forum Updated to NodeBB v4.3 + New Features

How to select row in QListView of QFileSystemModel ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.4k Views
  • 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    When I create a new file, the listview will update, but how can I use code to select the new file at row 0 ?

    directory = QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first() + "/HTYAR";
    model = new QFileSystemModel;
    model->setRootPath(directory);
    model->setNameFilterDisables(false);
    model->sort(3,Qt::DescendingOrder);
    ui->listView->setModel(model);
    ui->listView->setRootIndex(model->index(directory));
    

    alt text

    https://github.com/sonichy

    aha_1980A 1 Reply Last reply
    0
    • sonichyS sonichy

      When I create a new file, the listview will update, but how can I use code to select the new file at row 0 ?

      directory = QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first() + "/HTYAR";
      model = new QFileSystemModel;
      model->setRootPath(directory);
      model->setNameFilterDisables(false);
      model->sort(3,Qt::DescendingOrder);
      ui->listView->setModel(model);
      ui->listView->setRootIndex(model->index(directory));
      

      alt text

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sonichy does https://stackoverflow.com/questions/6925951/how-to-select-a-row-in-a-qlistview help you?

      Qt has to stay free or it will die.

      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