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. QSet::isEmpty() return's false while no data in it
QtWS25 Last Chance

QSet::isEmpty() return's false while no data in it

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 259 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.
  • Puppy BearP Offline
    Puppy BearP Offline
    Puppy Bear
    wrote on last edited by
    #1

    I've tried to compare 2 same list with
    QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());

    while print add_chart in qdebug , it shows in console like : QSet("")
    However,
    add_chart.isEmpty() still returns false,
    is there some reason in it and how to solve this?

    create a iterator to check if Qstring.isempty()?

    J.HilkJ 1 Reply Last reply
    0
    • Puppy BearP Puppy Bear

      I've tried to compare 2 same list with
      QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());

      while print add_chart in qdebug , it shows in console like : QSet("")
      However,
      add_chart.isEmpty() still returns false,
      is there some reason in it and how to solve this?

      create a iterator to check if Qstring.isempty()?

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

      @Puppy-Bear
      this QSet("") doesn't look empty, it seems like there's an empty QString in it -> isEmpty() will return false


      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
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Please show the real code, with correct test data so we can take a look what's wrong. This is fine for me:

        QList<QString> list1 = {"one", "two"};
        QList<QString> list2 = {"two", "one"};
        QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());
        qDebug() << add_chart;
        qDebug() << add_chart.isEmpty();
        return 0;
        

        -->

        QSet()
        true
        

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

        Puppy BearP 1 Reply Last reply
        1
        • Puppy BearP Puppy Bear

          I've tried to compare 2 same list with
          QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());

          while print add_chart in qdebug , it shows in console like : QSet("")
          However,
          add_chart.isEmpty() still returns false,
          is there some reason in it and how to solve this?

          create a iterator to check if Qstring.isempty()?

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

          @Puppy-Bear
          this QSet("") doesn't look empty, it seems like there's an empty QString in it -> isEmpty() will return false


          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
          3
          • Christian EhrlicherC Christian Ehrlicher

            Please show the real code, with correct test data so we can take a look what's wrong. This is fine for me:

            QList<QString> list1 = {"one", "two"};
            QList<QString> list2 = {"two", "one"};
            QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());
            qDebug() << add_chart;
            qDebug() << add_chart.isEmpty();
            return 0;
            

            -->

            QSet()
            true
            
            Puppy BearP Offline
            Puppy BearP Offline
            Puppy Bear
            wrote on last edited by Puppy Bear
            #4

            @Christian-Ehrlicher Sry it's a list of data from database, so it might cannot be showned on this screen yet. Guess it's something wrong with reading the db file

            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