Results 1 to 3 of 3

Thread: setViewMode issue of QFileDialog

  1. #1
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default setViewMode issue of QFileDialog

    Qt Code:
    1. QFileDialog l_pFiledDlg;
    2. QString sFilename1;
    3. l_pFiledDlg.setViewMode(QFileDialog::Detail);
    4. sFilename1 = l_pFiledDlg.getOpenFileName(this,tr("Open Files"), sPath, tr("All Files (*.*)"));
    To copy to clipboard, switch view to plain text mode 

    Using the above code the filedialog which opens is showing "list" as its view mode. It is not changing to "detail" view by default.

    I think everything seems correct, but I do not know why it is not working?

  2. #2
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setViewMode issue of QFileDialog

    QFileDialog::getOpenFileName is a static function. As such, it’s not using the l_pFiledDlg instance you created, so the QFileDialog::setViewMode has no effect. I think this:
    Qt Code:
    1. QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*.*)"));
    2. QString sFilename1;
    3. l_pFiledDlg.setViewMode(QFileDialog::Detail);
    4. if (l_pFiledDlg.exec()) sFilename1 = l_pFiledDlg.selectedFiles()[0];
    To copy to clipboard, switch view to plain text mode 
    should be close to what you want (though I haven’t tested it, so typos or outright errors would not be surprising).

  3. The following user says thank you to Coises for this useful post:

    nikhilqt (18th January 2010)

  4. #3
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: setViewMode issue of QFileDialog

    Thanks man! It worked. But the file dialog displayed has a different view unlike the static method of getOpenfilename(...).

Similar Threads

  1. QFileDialog issue
    By a_m_mukul in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2007, 23:46
  2. QFileDialog Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2007, 04:30
  3. QFileDialog Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 15:37
  4. QFileDialog Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2007, 13:47
  5. [Qt4] need help with QFileDialog
    By patcito in forum Qt Programming
    Replies: 2
    Last Post: 7th January 2006, 18:00

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.