Hello @all,
I spent the last 2 hours searching on Google for a problem that really annoys me, because even in outdated languages/IDEs like Delphi those things are fully implemented within seconds.
Simple task: I just want a QFileDialog to be opened when a QAction in a QMenu is triggered. I'm completely new to Qt, so I first wanted to get familiar with the signal-slot system. Seemed logical to me at first glance: Everytime the QAction is triggered (signal), the QFileDialog pops up (slot).
Now here is my main problem: How is the slot of QFileDialog called which lets it pop up? It would be easier if QFileDialog was an element in Qt Designer and accessable via signal & slot editor. But I can't even find an entry for it in the whole IDE.
Another Google recherche led me to the following code snippet:
tr("Open Image"), "/home", tr("Image Files (*.png *.jpg *.bmp)"));
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), "/home", tr("Image Files (*.png *.jpg *.bmp)"));
To copy to clipboard, switch view to plain text mode
So this is a piece of code which let a dialog pop up when the application is started. Fine. But I want it to be opened only when the entry in my QMenu is triggered.
One can manually connect a signal to a slot via connect(), but here an ID or name and a slot for the dialog is needed. Or am I completely wrong?
Hopefully, you can help me with this without letting me forget everything I learned about signals and slots so far.
Bookmarks