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 Customize the treeView?

How to Customize the treeView?

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

    I want to make the QTreeView show the data without files
    So I inherit QTreeView and override "isIndexHidden"
    But the customTreeView still show the files

    [code]
    class customTreeView : public QTreeView
    {
    protected:
    bool isIndexHidden( const QModelIndex &index ) const
    {
    QDirModel dirModel = static_cast<QDirModel>(model());
    qDebug() << dirModel->fileName(index);
    if(dirModel->fileInfo(index).isFile())
    return true;

        return false;
    }
    

    };

    inline int customTableViewTest(QApplication &app)
    {
    QDirModel model;

    QTreeView view;
    view.setModel(&model);
    
    customTreeView cView;
    cView.setModel(&model);
    
    QSplitter splitter;
    splitter.addWidget(&view);
    splitter.addWidget(&cView);
    splitter.show();    
    
    return app.exec&#40;&#41;;
    

    }
    [/code]

    How could I fix it?Thanks

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

      check this "post":http://qt-project.org/forums/viewthread/19522/

      However both the posts are same.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        Closing post as duplicate.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        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