Hi to all,
with a QFileDialog I choose a file in my hard disk to process it.
I would to print (with a cout) only the filename instead of the whole path.
Here the code
void CoinWidget::openAudioTrack()
{
tr("Audio (*.wav *.mp3);;All Files(*)"),
this,
"open file dialog",
"Choose an audio track");
if(!audioFileName.isEmpty())
{
cout << audioFileName.latin1() << endl; //<-----this print the whole path
// retrieve the root separator
SoSeparator *lroot = model->getRoot();//about coin3d
m_sound->setAudioTrack(audioFileName.latin1());
m_sound->enableContinuousPlay(true);
m_sound->setVolume(0.5f);
m_sound->playTrack();
}
else
{
cout << "No file selected" << endl;
return;
}
}
void CoinWidget::openAudioTrack()
{
QString audioFileName = QFileDialog::getOpenFileName( "../media",
tr("Audio (*.wav *.mp3);;All Files(*)"),
this,
"open file dialog",
"Choose an audio track");
if(!audioFileName.isEmpty())
{
cout << audioFileName.latin1() << endl; //<-----this print the whole path
// retrieve the root separator
SoSeparator *lroot = model->getRoot();//about coin3d
m_sound->setAudioTrack(audioFileName.latin1());
m_sound->enableContinuousPlay(true);
m_sound->setVolume(0.5f);
m_sound->playTrack();
}
else
{
cout << "No file selected" << endl;
return;
}
}
To copy to clipboard, switch view to plain text mode
Where I wrote "this print the whole path" I also would print the filename istead.
Any idea?
Regards
Bookmarks