Results 1 to 4 of 4

Thread: Qfiledialog Problem - (Beginner)

  1. #1
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Qfiledialog Problem - (Beginner)

    Hello guys,
    I create simple designer application.
    in which i implemeted a filedialog to retreive the file.

    I followed the documentation, and did it .
    It compiled & ran properly
    and when i click the button , it just access the floppy drive and then nothing happens

    <code>
    void VRML2MVRDlg:n_Browse_clicked()
    {
    // QString filename = QFileDialog::getOpenFileName( QString::null, "VRML Files (*.wrl)", this, "file open", "VRML File Open" );
    QFileDialog* fd = new QFileDialog(this);
    fd->setDirectory("C:\\");
    fd->setFileMode( QFileDialog::AnyFile);
    fd->setViewMode(QFileDialog:etail);
    fd->setFilter("VRML Files (*.wrl)");
    QStringList filenames = fd->selectedFiles();
    QString filename;
    if (!filenames.isEmpty())
    filename = filenames[0];
    }
    <code>

    Looking forward for your reply.

  2. #2
    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: Qfiledialog Problem - (Beginner)

    You have to call QDialog::exec() or QWidget::show() to make the file dialog visible. Most likely you want the first one which gives you a modal dialog (blocking until the user closes it).

    Qt Code:
    1. if (filedialog->exec() == QDialog::Accepted)
    2. {
    3. // do something
    4. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    kingslee (11th October 2006)

  4. #3
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qfiledialog Problem - (Beginner)

    Thanks jpn for your reply.
    Still I have a problem in displaying the file name in lineedit .
    again ..
    it compiles and nothing happens.

    I inserted two lines to do it. I dont kow whether its right or?
    m_VrmlFile is the object name of the lineedit.

    code

    QFileDialog* fd = new QFileDialog(this);
    if(fd->exec()== QDialog::Accepted)
    {
    fd->setDirectory("C:\\");
    fd->setFileMode( QFileDialog::ExistingFile);
    // fd->setViewMode(QFileDialog:etail);
    fd->setFilter("VRML Files (*.wrl)");
    QStringList filenames = fd->selectedFiles();
    QString filename;
    if (!filenames.isEmpty())
    filename = filenames[0];

    m_VrmlFile = new QLineEdit;
    m_VrmlFile->setText(filename);
    }

    looking forward to your reply

  5. #4
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qfiledialog Problem - (Beginner)

    i got it ..
    I should not use the first line, to create a new qlineedit object

    thanks.

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 13:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 22:36
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.