Page 2 of 2 FirstFirst 12
Results 21 to 32 of 32

Thread: Suggestions/Ideas about a file browser

  1. #21
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions/Ideas about a file browser

    Quote Originally Posted by jpn View Post
    Nice example. Thanks.

    But one question. When you doubleclick the treeview it will enter the clicked item...but if the item selected isnt the first column it will not enter the correct directory. Any thoughts on that?

  2. The following user says thank you to invictus for this useful post:

    jpn (6th November 2007)

  3. #22
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Suggestions/Ideas about a file browser

    connect clicked(const QModelIndex &) or doubleClicked(const QModelIndex &) signal to slot that setRootIndex ( const QModelIndex & ) for index in first column & the same row as passed in signal...

  4. #23
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Suggestions/Ideas about a file browser

    Quote Originally Posted by invictus View Post
    But one question. When you doubleclick the treeview it will enter the clicked item...but if the item selected isnt the first column it will not enter the correct directory. Any thoughts on that?
    Thanks for the bug report. It's fixed now.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    invictus (7th November 2007)

  6. #24
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions/Ideas about a file browser

    Speaking of problems...

    This is my goTo slot (much like your setRootIndex):

    void goTo(const QModelIndex &dir)
    {
    if(dirModel->isDir(dir))
    {
    dirView->setRootIndex(dir);
    addressField->setText(dirModel->filePath(dir));
    upAction->setEnabled(dir.isValid());
    }
    }
    dirView is a QTreeView. The problem is that when the up method is run (which run goTo() with the parent() of the dirView rootIndex like in your example) the program just quits/crashes. If I comment the if(dirView->isDir()) line it works.
    Last edited by invictus; 7th November 2007 at 22:10.

  7. #25
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Suggestions/Ideas about a file browser

    Did you notice that I modified the statement which enables/disables "upAction" in the example from
    Qt Code:
    1. upAction->setEnabled(listView->rootIndex().isValid());
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. upAction->setEnabled(!dirModel->fileInfo(listView->rootIndex()).isRoot());
    To copy to clipboard, switch view to plain text mode 
    ? The former works on Windows but not on Linux. On Linux, I experienced the same crash youre' talking about. The latter should work on both environments. Unfortunately I don't have a Mac so I don't know for sure if there's any pitfalls on that matter but I believe the latter should take care of it on Mac too..
    J-P Nurmi

  8. #26
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions/Ideas about a file browser

    Yeah, but its on the isDir() that it crashes. I am using windows btw.

    Perhaps the problem is that on Windows there is another level above the root ? its a list of partitions like "C:", "D:", etc...

  9. #27
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Suggestions/Ideas about a file browser

    To me this suggests that goTo() get called with an invalid index and QDirModel is missing sufficient checks. Does the example crash too?
    J-P Nurmi

  10. #28
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions/Ideas about a file browser

    Quote Originally Posted by jpn View Post
    To me this suggests that goTo() get called with an invalid index and QDirModel is missing sufficient checks. Does the example crash too?
    No...but then again, the example doesn't run model->isDir() on the level above the root (level above root is the list of filesystems on windows). Looks to me that this is a QT problem or something.

  11. #29
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Suggestions/Ideas about a file browser

    Quote Originally Posted by invictus View Post
    No...but then again, the example doesn't run model->isDir() on the level above the root (level above root is the list of filesystems on windows). Looks to me that this is a QT problem or something.
    Drives are "root" on Windows:
    Qt Code:
    1. qDebug() << QFileInfo("C:\\").isRoot(); // "true"
    To copy to clipboard, switch view to plain text mode 
    Notice that QDirModel::isDir() is basically a shortcut for QDirModel::fileInfo().isDir(). Also, calling QDirModel::fileInfo() or QDirModel::isDir() throws an assert when passed an invalid index:
    Qt Code:
    1. QDirModel model;
    2. QModelIndex index = model.index(0, 0);
    3. model.fileInfo(index.parent()); // "ASSERT: "d->indexValid(index)" in file itemviews\qdirmodel.cpp"
    To copy to clipboard, switch view to plain text mode 
    So you will have to take care of it yourself that you don't call QDirModel::fileInfo() or QDirModel::isDir() with an invalid index.
    J-P Nurmi

  12. #30
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Suggestions/Ideas about a file browser

    Hi,
    i had similar problems, when i was writing dirModel with Desktop myComputer & MyDocuments on top level and i'm quite sure that jpn has right there's no bugs on qt and errors you got are caused by passing unexisting modelIndexes to model...

    try to check hasIndex() for each QModelIndex you are using - it might be useful to find the error.

  13. #31
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Suggestions/Ideas about a file browser

    hello.// how an i load the files from the file list so that i an get its directory to load the file itself to transfer it to another device..thanks!

  14. #32
    Join Date
    Dec 2009
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suggestions/Ideas about a file browser

    Hi I'm doing that thing with the contents of clipboard.. ( a simple enumeration )

    const QMimeData *mime = QApplication::clipboard()->mimeData();
    if (mime && mime->hasUrls()) {
    QStringList fileList;
    foreach(QUrl url, mime->urls())
    fileList.append(url.toLocalFile());
    ........

    But If clipboard was filled by a windows application I can't know if I I need to copy or cut ..... do you know a trick ????

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. Adding property editor file browser popup...
    By thawkins in forum Qt Tools
    Replies: 1
    Last Post: 25th April 2007, 23:03
  4. Replies: 11
    Last Post: 4th July 2006, 15:09
  5. Opening swf file in the default browser
    By munna in forum Qt Programming
    Replies: 16
    Last Post: 5th May 2006, 09:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.