I'm just starting out on Qt (having a primary use for its file-picking dialogs) and created a very small code to test it out. The code is so far meaningless (doesn't do anything relevant), but I'm just testing the waters for now. (Nevermind the empty constructor and destructor, I deleted their contents since they're related to other things that don't matter here.
{
Q_OBJECT
public:
System();
~System();
public slots:
};
System::System()
{
}
{
a.show();
}
System::~System()
{
}
int main(int argc, char *argv[])
{
System c;
fd.show();
return app.exec();
}
class System : public QObject
{
Q_OBJECT
public:
System();
~System();
public slots:
void OpenFile(QStringList str);
};
System::System()
{
}
void System::OpenFile(QStringList str)
{
QFileDialog a;
a.show();
}
System::~System()
{
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
System c;
QFileDialog fd;
QObject::connect(&fd,SIGNAL(filesSelected(QStringList)),&c,SLOT(OpenFile(QStringList)));
fd.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
It's my understanding that the File Dialog should appear (which it does) and after I select a file and press okay, it should send a signal to c's OpenFile() function. If you notice, that function has nothing to do with the address because I'm just testing the SIGNAL-SLOT concept. I'm just expecting to see another FileDialog pop up, which it doesn't.
So, the program runs, the first file dialog (fd) appears, I select a file, press okay, the dialog disappears and, instead of showing a second dialog, the program simply comes to an end.
So, either there's something wrong with my understanding/construct of the QFileDialog, of the SIGNAL-SLOT mechanism or of the workings of a function that is called by this mechanism. I'm quite stumped on this issue, I must say.
I'm on Qt 4.6.3 on VC2008.
Bookmarks