Removing extension of a file name in Qt

c++, qt

Solution

You can `split` `fileName` with "." as separator like this:

QString croped_fileName=fileName.split(".",QString::SkipEmptyParts).at(0);

or use `section` function of QString to take the first part before "." like this:

QString croped_fileName=fileName.section(".",0,0);

Problem

I'm using Qt to get a file name from the user: ``` QString fileName = QFileDialog::getOpenFileName(this,tr("Select an image file"),"d:\\",tr("Image files(*.tiff *.tif )")); ``` It works, but I need the file name without its extension, is it possible in Qt?? whenn I try : ``` QString f = QFileInfo(fileName).fileName(); ``` `f` is like "filename.tif", but I want it to be "filename".

Original source