Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Feedback on my idea of a new Function for the QString class
Forum Updated to NodeBB v4.3 + New Features

Feedback on my idea of a new Function for the QString class

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wonopon12
    wrote on last edited by
    #1

    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;
    

    }
    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        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.
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved