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. Help with deprecated code

Help with deprecated code

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 888 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.
  • L Offline
    L Offline
    leinad
    wrote on last edited by VRonin
    #1

    Hi,

    I had this code working fine in 5.12.4 but when I upgraded to 5.15, I now get warnings on this deprecated code. Any ideas how to fix it?

            std::sort(list.begin(), list.end(),[column,order](const QList<QVariant>list, const QList<QVariant>list1)->bool
        
            {
        
                const auto aV = list.at(column);  
                const auto bV = list1.at(column);
        
                if(order == Qt::AscendingOrder)
        
                return aV == bV ? list.at(1) < list1.at(1) : aV < bV;
    return aV == bV ? list.at(1) > list1.at(1) : aV > bV;
        });
    
    1 Reply Last reply
    0
    • L Offline
      L Offline
      leinad
      wrote on last edited by
      #2

      Sorry, I for got to add that these lines are deprecated:
      return aV == bV ? list.at(1) < list1.at(1) : aV < bV; //qt does not like '<'
      return aV == bV ? list.at(1) > list1.at(1) : aV > bV; //qt does not like '>'

      JonBJ 1 Reply Last reply
      0
      • L leinad

        Sorry, I for got to add that these lines are deprecated:
        return aV == bV ? list.at(1) < list1.at(1) : aV < bV; //qt does not like '<'
        return aV == bV ? list.at(1) > list1.at(1) : aV > bV; //qt does not like '>'

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @leinad
        bool QVariant::operator<(const QVariant &v) const is deprecated as per https://doc.qt.io/qt-5/qvariant-obsolete.html#operator-lt.

        1 Reply Last reply
        1
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          basically you need to convert them into the underlying type before comparing them

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          3
          • L Offline
            L Offline
            leinad
            wrote on last edited by
            #5

            Yes, but would you know how to fix this particular issue?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leinad
              wrote on last edited by
              #6

              OK, I see. I converted to QString which seems to fix the error.

              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