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. Remove string from QStringList with higher number
QtWS25 Last Chance

Remove string from QStringList with higher number

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 267 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on last edited by
    #1

    I have some elements in QString List as below

    Test_String1-1
    Test_String2-2
    Test_String1-2
    Test_String1-3
    Test_String2-10
    Test_String3-1
    Test_String4-1
    Test_String3-3

    I need to remove all the string with lower end number for example only string with name
    Test_String1-<number> with highesht number should be in list and rest other lower number should be removed

    so output should be in QStringList should contain only below elements

    Test_String1-3
    Test_String2-10
    Test_String3-3
    Test_String4-1

    Please suggest how to do this

    Pl45m4P 1 Reply Last reply
    0
    • A Ayush Gupta

      I have some elements in QString List as below

      Test_String1-1
      Test_String2-2
      Test_String1-2
      Test_String1-3
      Test_String2-10
      Test_String3-1
      Test_String4-1
      Test_String3-3

      I need to remove all the string with lower end number for example only string with name
      Test_String1-<number> with highesht number should be in list and rest other lower number should be removed

      so output should be in QStringList should contain only below elements

      Test_String1-3
      Test_String2-10
      Test_String3-3
      Test_String4-1

      Please suggest how to do this

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Ayush-Gupta

      Is this a coding issue or are you looking for an algorithm, which will filter your QStringList?

      If all your strings have this structure (one number before and one number after a '-'), you can separate the strings and compare each 'group' to get the highest final digit of e.g. String3 - group.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      4
      • A Offline
        A Offline
        Ayush Gupta
        wrote on last edited by
        #3

        @Pl45m4 I am looking for algorithm. Can you please help ?

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Ayush-Gupta said in Remove string from QStringList with higher number:

          I am looking for algorithm. Can you please help ?

          @Pl45m4 already told you how to do it.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

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