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. Selection in a QFileSystemModel and QTreeView
Forum Updated to NodeBB v4.3 + New Features

Selection in a QFileSystemModel and QTreeView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.6k 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.
  • S Offline
    S Offline
    sheehan1234
    wrote on last edited by
    #1

    I've created a QTreeView with a QFileSystemModel for the user to select a file to be used by the rest of the program. I'm having trouble obtaining the selected file as a QString. Currently I have this function:

    @void MyWidget::setFileName()
    {
    file = "";
    file.append(model.data(tree.currentIndex(), Qt::DisplayRole).toString());
    }@
    Where model is the QFileSystemModel and tree is the QTreeView

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      bq. Note: If you do not have a value to return, return an invalid QVariant instead of returning 0.

      This note is taken from "the official documentation of QAbstractItemModel which is inherited by QFileSystemModel ":http://doc.qt.nokia.com/4.7-snapshot/qabstractitemmodel.html#data Do you get invalid QVariant in your case?

      http://anavi.org/

      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