0

I'm using QTreeView together with QFileSystemModel to display content of a directory like this

tree view displaying directory

However as you can see, if the sub-directories go too deep, the text is clipped and becomes unreadable. I would like to rather have a horizontal scrollbar that will allow me to see the full names. Anyone knows how to do it?

If you're interested how my view and model is initialized, then this is how

    ui->mapDirView->setModel( &mapModel );

    ui->mapDirView->setSelectionMode( QAbstractItemView::ExtendedSelection );

    mapModel.setFilter( QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks );
    mapModel.setNameFilters( getModFileSuffixes() );
    mapModel.setNameFilterDisables( false );

    ui->mapDirView->setHeaderHidden( true );

    for (int i = 1; i < mapModel.columnCount(); ++i)
        ui->mapDirView->hideColumn(i);

    class EmptyIconProvider : public QFileIconProvider
    {
     public:
        virtual QIcon icon( IconType ) const override { return QIcon(); }
        virtual QIcon icon( const QFileInfo & ) const override { return QIcon(); }
    };
    mapModel.setIconProvider( new EmptyIconProvider );

although i doubt any of this is the cause.

Youda008
  • 1,788
  • 1
  • 17
  • 35
  • I suspect you're looking for some combination of [`QTreeView::resizeColumnToContents`](https://doc.qt.io/qt-6/qtreeview.html#resizeColumnToContents) and [`QTreeView::setResizeContentsPrecision`](https://doc.qt.io/qt-6/qheaderview.html#setResizeContentsPrecision). – G.M. Sep 10 '22 at 09:38

0 Answers0