Nominate our 2022 Qt Champions!

QFileDialog::getOpenFileName linux doesn't work

  • Hello
    I have a problem using QFileDialog::getOpenFileName and it does the same for QFileDialog in general.

    I have linux ubuntu 12.04 64 bits, Qt Creator 2.4.1 , Qt 4.8.0 (64 bit).

    I have a simple code with one button:

    void MainWindow::on_pushButton_3_clicked()

    QString cheminFichier = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "Text file (*.txt)",0,QFileDialog::DontResolveSymlinks|QFileDialog::DontUseNativeDialog|QFileDialog::DontUseSheet );


    There are no errors in compilation , no crashes , but when I press the button , nothing happens. I tried with other QFileDialog function and it doesn't work also.

    (When I try to use QFileDialog on windows 7 64 bit , QT crashes during compilation)

    Could you help me to solve this , to open FileDialog window on linux ? Maybe there are other solutions.
    thanks :)

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The question might be silly but: are you sure that this slot is called ?

    You should also consider updating your Qt version, the latest (and last) version of Qt 4 is 4.8.7.

    What version of Qt are you using on Windows ? What do you mean by crash during compilation ?

  • Problem solved , thanks to your silly question :p

    In deed the slot wasn't called because before I probably put an other button that I deleted with the same name .
    So I changed name here and deleted the previous switch case of the previous button in "moc_mainwindow.cpp".

    On windows I have Qt5.5 and I meant that Qt is frozen. Probably with the right file now it won't do anymore.

    Thanks :)

  • Lifetime Qt Champion

    @bejard You should never edit moc_*.cpp files, they are generated during compilation!
    What do you mean by "Qt is frozen"? Do you mean QtCreator is frozen? Qt is a framework, it cannot be frozen during compilation.

  • @jsulm yes but as I deleted in wrong way the previous button I had still it in this file and it did some errors ^^ now it works I saved it.
    I meant QtCreator yes : loading loading loading at middle of compilation ...then "not responding"
    Forced to kill the task

  • Lifetime Qt Champion

    Instead of editing the moc file you can just rebuild you project completely (you can delete the build folder before you rebuild).

Log in to reply