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. qcolumnview, how to determine whether it is a file

qcolumnview, how to determine whether it is a file

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 416 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.
  • J Offline
    J Offline
    Johan
    wrote on last edited by
    #1

    Hello, everyone

    I has a problem when the qcolumnview was used to show the file system tree.

    first, I set the rootpath

    void MainWindow::on_actionOpen_Image_triggered()
    {
        FileImgDir = QFileDialog::getExistingDirectory(this,tr("Select a directory including Images(*.jpg,*.tif,*,png,*.txt,*.bmp)"),"/home",QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
    
        QStringList filters;
        filters << "*.jpg"<<"*.JPG"<<"*.tif"<<"*.TIF"<<"*.tiff"<<"*.TIFF"<<"*.png"<<"*.PNG"<<"*.txt"<<"*.TXT"<<"*.bmp"<<"*.BMP";
        imgmodel->setNameFilters(filters);     //imgmodel is an object of the filesystemmodel
        ui->Image_filenames_columnview->setModel(imgmodel);
        ui->Image_filenames_columnview->setRootIndex(imgmodel->setRootPath(FileImgDir));
    }
    
    

    define the slot function for the signal click.

    
    void MainWindow::on_Image_filenames_columnview_clicked(const QModelIndex &index)
    {
    Path_Img_Name=imgmodel->fileInfo(index).absolutePath() + "/" + index.data().toString();
    
        filename = Path_Img_Name.toStdString();
    }
    

    it is working for the file name, but do not for directory name.
    I know it would not work on the directory name, the file name and directory name are differrent represented in the qmodelindex. But I do not know how to handle them.

    default action of the signal click for directory is to open it in the next column, but do not work, how implement it again in the slot function?

    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