Feedback on my idea of a new Function for the QString class
-
Hey everyone, I was thinking of adding this is a contribution for Qt. Tell me what you think please :D
@
QString GetFileExtension(QString filename)
{
int position_dot = filename.lastIndexOf(".");
int final = filename.size() - position_dot;QString ext = filename.right(final - 1); // example : file.txt will return "txt" return ext;
}
QString GetFileExtension(QFile file)
{
QString filename = file.fileName();
int position_dot = filename.lastIndexOf(".");
int final = filename.size() - position_dot;QString ext = filename.right(final - 1); return ext;
}
@ -
Sorry, but I think there is already a "class and a method available ":http://developer.qt.nokia.com/doc/qt-4.8/qfileinfo.html#suffix
-
Although I approve people contributing to Qt, thumbs down from me too, mostly because
- as koahnig mentioned there is already such functionality,
- not every QString contains a file, even more, most probably the most QString objects do not contain filenames, thus both members are misplaced in QString,
- the methods do not comply with the Qt naming conventions.