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. how to compare the last three characters of QSTring is png

how to compare the last three characters of QSTring is png

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 3.0k Views
  • 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 Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    how to compare the last three characters of QSTring is png

    kshegunovK 1 Reply Last reply
    0
    • Q Qt Enthusiast

      how to compare the last three characters of QSTring is png

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      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
      2
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

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

        J.HilkJ kshegunovK 2 Replies Last reply
        0
        • Q Qt Enthusiast

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

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @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


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

          1 Reply Last reply
          0
          • Q Qt Enthusiast

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

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @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
            1
            • G Offline
              G Offline
              Gerd
              wrote on last edited by
              #6

              just use

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

              Regards
              gerd

              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