Results 1 to 4 of 4

Thread: dialog box

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default dialog box

    Hi,

    In a Qt project, when clicked on the browse button, I want the dialog box to show the files of a certain directory, not the directory that is lastly seen. Is there any way to control the directory shown by the dialog box. I mean, I want the dialog box to open a specific directory in order to ease the job of the user. I hope i could explain my problem.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dialog box

    Quote Originally Posted by Qt4 Docs :-p
    QString QFileDialog::getOpenFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 ) [static]

    This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string.
    QString s = QFileDialog::getOpenFileName( this, "Choose a file to open", "/home", "Images (*.png *.xpm *.jpg)");The function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
    The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the given filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can pass.
    The dialog's caption is set to caption. If caption is not specified then a default caption will be used.
    Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog.
    Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar.
    Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If options includes DontResolveSymlinks, the file dialog will treat symlinks as regular directories.

    QStringList QFileDialog::getOpenFileNames ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 ) [static]

    This is a convenience static function that will return one or more existing files selected by the user.
    QStringList files = QFileDialog::getOpenFileNames( this, "Select one or more files to open", "/home", "Images (*.png *.xpm *.jpg)");This function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
    The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. The filter is set to filter so that only those files which match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter and filter may be empty strings.
    The dialog's caption is set to caption. If caption is not specified then a default caption will be used.
    Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog.
    Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar.
    Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. The options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can pass.
    I doubt you can need more!
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: dialog box

    are you mean QFileDialog?
    if yes look here
    Qt Code:
    1. QFileDialog fd (QDir::currentDirPath());
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: dialog box

    That's it. Thanks zlatko.

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 11:10
  2. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 18:04
  3. Replies: 9
    Last Post: 13th August 2008, 19:07
  4. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 11:41
  5. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 18:48

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.