Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved how to compare the last three characters of QSTring is png

    General and Desktop
    4
    6
    1814
    Loading More Posts
    • 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.
    • Q
      Qt Enthusiast last edited by

      how to compare the last three characters of QSTring is png

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @Qt Enthusiast last edited by

        Don't use QString but QFileInfo for this. There's the corresponding API to work with file extensions.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 2
        • Q
          Qt Enthusiast last edited by

          but we if have to incliue a extra header file , will no increase the executable size

          J.Hilk kshegunov 2 Replies Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @Qt Enthusiast last edited by

            @Qt-Enthusiast
            if you insist on it, there are still the standart QString functions
            splitRef & rightRef and char wise comparing.

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @Qt Enthusiast last edited by

              @Qt-Enthusiast said in how to compare the last three characters of QSTring is png:

              but we if have to incliue a extra header file , will no increase the executable size

              How do you figure this? There's no relation between headers of non-template classes (except for the ones containing inline functions) and binary size.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 1
              • G
                Gerd last edited by

                just use

                QString s;
                bool endsWithpng = false;
                endsWithpng = s.endsWith("png",Qt::CaseInsensitive);

                Regards
                gerd

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post