Results 1 to 1 of 1

Thread: How to only show (more than one) U disks in QTreeView , all as root ?

  1. #1
    Join Date
    Dec 2016
    Qt products
    Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Unix/X11 Windows Android

    Default Re: How to only show (more than one) U disks in QTreeView , all as root ?

    When one U disk was plugged in system , it shows in the QTreeView by QFileSystemModel as root .
    The method is to hide other partitions expcet the U disk's . Like attached picture.

    like this:

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    model = new QFileSystemModel;

    listView = new QTreeView;

    QModelIndex root = model->index("d:", 0);

    for (int i=67; i<=90; i++) {
    QChar ch(i);
    QString str(ch);
    qDebug() << str;
    QModelIndex node = model->index(str, 0);
    if (node==root) continue;
    for (int j=1; j<26; j++) {
    //listView->setRowHidden(0, node.parent(), true); // OK
    listView->setRowHidden(j, node.parent(), true); // OK

    But when one U disks was plugged in system , how to show them like this style? Just show these U disks partitions in the QTreeView , and all as root.
    I have tried the upper method , but failed .
    Attached Images Attached Images
    Last edited by CyberPunker; 27th August 2018 at 07:47.

Similar Threads

  1. Replies: 7
    Last Post: 4th July 2015, 12:41
  2. Need to remove root node from QTreeView
    By tescik in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2014, 10:54
  3. Replies: 1
    Last Post: 6th March 2011, 09:48
  4. Replies: 7
    Last Post: 7th December 2010, 05:36
  5. QTreeView: include root in tree?
    By meter in forum Newbie
    Replies: 2
    Last Post: 14th June 2010, 13:59


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.