Hard crash in QFileDialog (Qt/WinFree)
Angus Leeming <[email protected]>
| Newsgroups | gmane.comp.kde.devel.cygwin,gmane.editors.lyx.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi guys.
I've compiled the attached files with:
$ moc -o trial_moc.cpp trial.h
$ g++ -g -I$HOME/qt3/include -o trial trial.cpp trial_moc.cpp \
-L$HOME/qt3/lib -lqt-mt
On launching the resulting trial.exe, a little push button pops up.
Press the button and a QFileDialog is displayed.
Press the "Up folder" button to the right of the "Look in:" widget which
should be showing you're in "My Documents".
Select (double click on) the "Desktop" folder, to enter this directory.
Press "a" on the keyboard...
BOOM.
and now, I'm off to bed.
Good night,
Angus
_______________________________________________
kde-cygwin mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-cygwin
trial.cpp
(text/plain, 1.5 KB)
/*
* moc -o trial_moc.cpp trial.h
* g++ -g -I$HOME/qt3/include -o trial trial.cpp trial_moc.cpp \
* -L$HOME/qt3/lib -lqt-mt
*/
#include "trial.h"
#include <qapplication.h>
#include <qfiledialog.h>
#include <qpushbutton.h>
#include <iostream>
#include <string>
using std::string;
React::React(std::string const & folder_path, QWidget * parent)
: folder_path_(folder_path), parent_(parent)
{
connect(parent_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
}
void React::buttonClicked()
{
QFileDialog dlg(folder_path_, "All files (*)",
parent_, "Crashing test", true);
dlg.setMode(QFileDialog::AnyFile);
std::cerr << "Launching FileDialog...\n";
int const result = dlg.exec();
std::cerr << "Result " << result << '\n';
dlg.hide();
}
string const my_documents_path();
int main(int argc, char * argv[])
{
string const my_documents = my_documents_path();
if (my_documents.empty()) {
std::cerr << "Cannot find \"My Documents\" folder\n";
return 1;
}
QApplication a(argc, argv);
QPushButton hello("hello", 0);
hello.resize(100, 30);
React reactor(my_documents, &hello);
a.setMainWidget(&hello);
hello.show();
return a.exec();
}
# include <windows.h>
# include <shlobj.h> // SHGetFolderPath
// Needed for MinGW:
# ifndef SHGFP_TYPE_CURRENT
# define SHGFP_TYPE_CURRENT 0
# endif
string const my_documents_path()
{
char folder_path[PATH_MAX + 1];
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PERSONAL, 0,
SHGFP_TYPE_CURRENT, folder_path)))
return folder_path;
return string();
}
trial.h
(text/plain, 311 B)
// -*- C++ -*-
#ifndef TRIAL_H
#define TRIAL_H
#include <qwidget.h>
#include <string>
class React: public QObject
{
Q_OBJECT
public:
React(std::string const & folder_path, QWidget * parent);
public slots:
void buttonClicked();
private:
std::string folder_path_;
QWidget * parent_;
};
#endif // TRIAL_H