Page 2 of 2 FirstFirst 12
Results 21 to 28 of 28

Thread: Including 3rd party software makes my program crash with QFileDialog

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

    Default Re: Replace QFileDialog

    Could we focus on the minimal example please?
    Compile this one and see if it crashes on you. If it does, provide a backtrace and ldd of the program and libQtCore.so
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv){
    4. QApplication app(argc, argv);
    5. QFileDialog::getOpenFileName();
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    and this project file:
    qmake Code:
    1. TEMPLATE=app
    2. SOURCES += main.cpp
    3. LIBS += -L/opt/halcon/lib/x64-linux2.4-gcc40 -lhalcon -lhalconcpp
    To copy to clipboard, switch view to plain text mode 

    And please post the result of "gcc -v" and "uname -rm" on your system.
    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.


  2. #22
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Replace QFileDialog

    Quote Originally Posted by wysota View Post
    Could we focus on the minimal example please?
    Compile this one and see if it crashes on you. If it does, provide a backtrace and ldd of the program and libQtCore.so
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv){
    4. QApplication app(argc, argv);
    5. QFileDialog::getOpenFileName();
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    and this project file:
    qmake Code:
    1. TEMPLATE=app
    2. SOURCES += main.cpp
    3. LIBS += -L/opt/halcon/lib/x64-linux2.4-gcc40 -lhalcon -lhalconcpp
    To copy to clipboard, switch view to plain text mode 

    And please post the result of "gcc -v" and "uname -rm" on your system.
    main.cpp:


    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv){
    4. QApplication app(argc, argv);
    5. QFileDialog::getOpenFileName();
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 


    pro file:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET = filedialog_test
    3. QT += core
    4. SOURCES += main.cpp
    5. LIBS += -L/opt/halcon/lib/x64-linux2.4-gcc40 -lhalcon -lhalconcpp
    To copy to clipboard, switch view to plain text mode 

    gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
    2.6.28-19-generic x86_64

    backtrace as attachment.

    thank you!
    Attached Files Attached Files

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

    Default Re: Replace QFileDialog

    I don't think we will solve this here. The crash is deep inside Gnome's libraries. If you ran your app in KDE, it would probably work. I can only suggest a workaround - pass DontUseNativeDialog option to QFileDialog. You will then get Qt's own file dialog instead of the one native to your desktop and with a bit of luck it will not crash. Unless it is libpng which causes the crash. You either have a misconfiguration in your system or these halon libs are really messed up. With a bit of bad luck it is probable that every call to libpng will end up with a crash.
    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.


  4. The following user says thank you to wysota for this useful post:

    ruben.rodrigues (25th January 2011)

  5. #24
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Replace QFileDialog

    Quote Originally Posted by wysota View Post
    I don't think we will solve this here. The crash is deep inside Gnome's libraries. If you ran your app in KDE, it would probably work. I can only suggest a workaround - pass DontUseNativeDialog option to QFileDialog. You will then get Qt's own file dialog instead of the one native to your desktop and with a bit of luck it will not crash. Unless it is libpng which causes the crash. You either have a misconfiguration in your system or these halon libs are really messed up. With a bit of bad luck it is probable that every call to libpng will end up with a crash.
    Hey! It works if I use the option DontUseNativeDialog. I am still figuring out how to get the value of the search because I just tested like this:

    QFileDialog dlg(this);
    dlg.setOption(QFileDialog:ontUseNativeDialog, false);
    dlg.exec();

    If I do this:

    QString fileName = QFileDialog::getOpenFileName(this, tr("OpenFile: "),"/home/rrodrigues/Desktop",QFileDialog:ontUseNativeDialog);

    or

    QString fileName = QFileDialog::getOpenFileName(this, tr("OpenFile: "),QString("/home/rrodrigues/Desktop"),QFileDialog:ontUseNativeDialog);

    it tell me no matching function:

    no matching function for call to ‘QFileDialog::getOpenFileName(ldiclient* const, QString, const char [25], QFileDialog::Option)’
    no matching function for call to ‘QFileDialog::getOpenFileName(ldiclient* const, QString, QString, QFileDialog::Option)’

    I am already very happy that I can see the dialog but can you tell me what is wrong with the function?

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

    Default Re: Replace QFileDialog

    Look at the available variants of getOpenFileName(), the Options argument is the last one so you have to explicitly pass all the previous ones.
    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.


  7. #26
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Replace QFileDialog

    I tried like this but it doesn't work: (it terminates like it used before)

    QFileDialog dlg(this);
    dlg.setOption(QFileDialog::DontUseNativeDialog, false);
    QString test = dlg.getOpenFileName();
    dlg.exec();
    cout << test.toStdString() << endl;

    If I do it like this it works but I can't get the file name:

    QFileDialog dlg(this);
    dlg.setOption(QFileDialog::DontUseNativeDialog, false);
    dlg.exec();

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

    Default Re: Replace QFileDialog

    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
    2. "/home",
    3. tr("Images (*.png *.xpm *.jpg)"), 0, QFileDialog::DontUseNativeDialog);
    To copy to clipboard, switch view to plain text mode 

    or
    Qt Code:
    1. QFileDialog dlg(this); // you don't need to set DontUseNativeDialog here
    2. QStringList selectedFiles;
    3. if(dlg.exec()){
    4. selectedFiles = dlg.selectedFiles();
    5. }
    To copy to clipboard, switch view to plain text mode 
    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.


  9. The following user says thank you to wysota for this useful post:

    ruben.rodrigues (25th January 2011)

  10. #28
    Join Date
    Jun 2010
    Posts
    100
    Thanks
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Replace QFileDialog

    Quote Originally Posted by wysota View Post
    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
    2. "/home",
    3. tr("Images (*.png *.xpm *.jpg)"), 0, QFileDialog::DontUseNativeDialog);
    To copy to clipboard, switch view to plain text mode 

    or
    Qt Code:
    1. QFileDialog dlg(this); // you don't need to set DontUseNativeDialog here
    2. QStringList selectedFiles;
    3. if(dlg.exec()){
    4. selectedFiles = dlg.selectedFiles();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Thanks a lot man! it works like a charm now. it was kind of a weird error but good thing that qt has this DontUseNativeDialog thing.

    Also sorry for the delay but I was busy with other parts of the project.

Similar Threads

  1. Program Crash
    By jonmatteo in forum Qt Programming
    Replies: 5
    Last Post: 17th June 2009, 14:47
  2. Crash due to usage of QModelIndex inside QFileDialog?
    By mails.hemant in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2008, 09:23
  3. Replies: 2
    Last Post: 13th August 2008, 17:46
  4. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44
  5. Replies: 1
    Last Post: 20th January 2006, 12:01

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
  •  
Qt is a trademark of The Qt Company.