Reputation: 5422
I have a program in which I have a button to get File Dialog like
How can I select a file, get the file name and location, and save that to a string displayed in the ui.The signalclicked()
, emitted from the button, is connected to the slot fileSELECT()
.
........
void MainThread::fileSELECT(){
QString fileName = QFileDialog::getOpenFileName(this,tr("Select video"),"d:\\BMDvideos",tr("Video files (*.avi)"));
}
so when I select an .avi file, how do I get its location in fileName displayed like
d:\BMDvideo\videFile.avi
Upvotes: 0
Views: 8990
Reputation: 5422
so I thinks that I got it now. my first code was completly wrong.
void MainThread::fileSelect(){
QString fileName = QFileDialog::getOpenFileName(this,tr("Select video"),"d:\\BMDvideos",tr("Video files (*.avi)"));
QLabel *testLabel = new QLabel(fileName);
BOX->addWidget(testLabel);
}
I can see now the path of the selected file
Upvotes: 1
Reputation: 359
To get the folder path, you can use QFileDialog::getExistingDirectory
, and to get the file-name use QFileDialog::getOpenFileName
Upvotes: 0