Results 1 to 11 of 11

Thread: Customize QFileDialog

  1. #1
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Customize QFileDialog

    I have my FileDialog here:
    Qt Code:
    1. QStringList fileNames;
    2.  
    3. box.setFileMode(QFileDialog::ExistingFile);
    4. if (box.exec())
    5. {
    6. fileNames = box.selectedFiles();
    7. }
    To copy to clipboard, switch view to plain text mode 

    It works on a button click just fine. Am I able to streamline what it looks like? I'm not interested in having the user open or choose files but rather just view that files are present. Really what would be perfect would be a windows explorer type window where I could view files / not only the directories. Is there anything out there for what I've described? thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Customize QFileDialog

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Re: Customize QFileDialog

    Quote Originally Posted by wysota View Post
    Cool, thank you!

    Here's what I came up with, but why does it launch so slow (~10 seconds) when I try to display all drives ("\\"). It's as fast as you would expect when you only choose "C:\\"

    Qt Code:
    1. QSplitter *splitter = new QSplitter;
    2. QDirModel *model = new QDirModel;
    3. model->setFilter( QDir::AllEntries | QDir::NoDotAndDotDot ) ;
    4. QTreeView *tree = new QTreeView(splitter);
    5. tree->setModel(model);
    6.  
    7. tree->setRootIndex(model->index( "\\" ));
    8.  
    9. splitter->setWindowTitle("Quick Look");
    10. splitter->show();
    To copy to clipboard, switch view to plain text mode 
    Last edited by Swankee; 20th November 2009 at 17:09.

  4. #4
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Re: Customize QFileDialog

    Quote Originally Posted by Swankee View Post
    Cool, thank you!

    Here's what I came up with, but why does it launch so slow (~10 seconds) when I try to display all drives ("\\").

    Qt Code:
    1. QSplitter *splitter = new QSplitter;
    2. QDirModel *model = new QDirModel;
    3. model->setFilter( QDir::AllEntries | QDir::NoDotAndDotDot ) ;
    4. QTreeView *tree = new QTreeView(splitter);
    5. tree->setModel(model);
    6.  
    7. tree->setRootIndex(model->index( "\\" ));
    8.  
    9. splitter->setWindowTitle("Quick Look");
    10. splitter->show();
    To copy to clipboard, switch view to plain text mode 
    Can anyone lend a hand?

    thanks!

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Customize QFileDialog

    Because QDirModel is slow. Contrary to QFileSystemModel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Re: Customize QFileDialog

    Good to know.

    Would you mind assisting with a piece of code?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Customize QFileDialog

    Try and see.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Re: Customize QFileDialog

    Here's what I was able to come up with but it's not displaying on click. It compiles but it doesnt' work. Could you help me get it to display?

    Qt Code:
    1. QFileSystemModel *model = new QFileSystemModel(this);
    2. model->setResolveSymlinks(true);
    3. QModelIndex root = model->setRootPath(QDir::rootPath());
    4. this->setVisible(model);
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Customize QFileDialog

    Qt Code:
    1. this->setVisible(model);
    To copy to clipboard, switch view to plain text mode 
    This doesn't make much sense. What do you expect it to do?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    2

    Default Re: Customize QFileDialog

    Quote Originally Posted by wysota View Post
    Qt Code:
    1. this->setVisible(model);
    To copy to clipboard, switch view to plain text mode 
    This doesn't make much sense. What do you expect it to do?
    I ended up getting it working. I thought that would set the model visible, no?

    Here it is:
    Qt Code:
    1. QFileSystemModel *model = new QFileSystemModel;
    2. model->setRootPath("");
    3. QTreeView *tree = new QTreeView();
    4. tree->setModel(model);
    5.  
    6. QString title("Quick Look");
    7. tree->setWindowTitle(title);
    8.  
    9. tree->show();
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Customize QFileDialog

    Model is just a concept, it can't be made "visible".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Customizing QFileDialog
    By ScabrusMantra in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2011, 12:03
  2. QFileDialog - will be closed after selecting a file
    By skyperhh in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 16:49
  3. The problem of customize QtEmbedded-4.5.0 for arm920t board!
    By jeazh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd May 2009, 19:35
  4. QFileDialog in Qt designer
    By tpf80 in forum Qt Tools
    Replies: 1
    Last Post: 17th May 2007, 00:41
  5. QFileDialog Mac / PC
    By hey in forum Qt Programming
    Replies: 3
    Last Post: 26th April 2007, 18:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.