How to launch a file browser in a Qt application?
-
I want to have a button that, when clicked, launches a file browser (like Ctrl + O in Word) and returns the path of the file that user opens.
it's better to give source code to understand
thanks -
Have a look at "QFileDialog":http://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html:
bq. The QFileDialog class provides a dialog that allow users to select files or directories.
-
could you give some source codes?
-
[quote author="mohamaddanesh44" date="1378712814"]could you give some source codes?[/quote]
Did you open the link leon.anavi posted?
The most important Qt docs also provide source code examples. -
source codes would be appriciated
-
As raven-worx said, you have all the code examples needed in the "documentation":http://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html#details asking for them again means that you didn't take the time to read them. Doing so won't encourage people to help you.
-
There is lots of code that won't help you, and lots that will. You have to pick to the best of your knowledge. Others may help you decide.
Is there a specific reason why you need a solution handed to you? Everybody was a beginner once, that's no shame!
-
i want it to have a button for attach some files
-
Then go have a look at "QPushButton":http://qt-project.org/doc/qt-4.8/qpushbutton.html and "QFileDialog":http://qt-project.org/doc/qt-4.8/qfiledialog.html .
This very simple use case is described in the documentation of those classes. Also there are lots of "Qt examples":http://qt-project.org/doc/qt-4.8/all-examples.html that demostrate this.Have you even tried to look for yourself?
-
i dont have enough time to read docs. it's force major
-
A forced major?
@void openWindow()
{
QMessageBox m;
m.setText(QString::fromLatin1(QByteArray::fromBase64("QW0gSSBsYXp5IGFzIGhlbGw/")));
m.setWindowTitle("Choose one:");
m.setStandardButtons((QMessageBox::StandardButton)0x4000 | (QMessageBox::StandardButton)0x1000);
m.setDefaultButton((QMessageBox::StandardButton)0x4000);
m.setEscapeButton((QMessageBox::StandardButton)0x4000);
m.button((QMessageBox::StandardButton)0x1000)->setDisabled(true);
m.addButton("attach some files", (QMessageBox::ButtonRole)(-1))->hide();
m.exec();
}@And, for reference: "click":http://qt-project.org/doc/qt-5.1/qtwidgets/qfiledialog.html#getOpenFileNames
-
[quote] i dont have enough time to read docs. it’s force major [/quote]
You don't have time to read but you have time to wait one complete day to get an answer in a forum ? Hopeless. -
fuck u
-
[quote author="mohamaddanesh44" date="1378812846"]fuck u[/quote]
so you are on your own now .... good luck and have fun! -
:D i did what i wanted