Qt Forum

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

    Solved Help with deprecated code

    General and Desktop
    3
    6
    417
    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.
    • L
      leinad last edited by VRonin

      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 Reply Quote 0
      • L
        leinad last edited by

        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 '>'

        JonB 1 Reply Last reply Reply Quote 0
        • JonB
          JonB @leinad last edited by

          @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 Reply Quote 1
          • V
            VRonin last edited by

            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 Reply Quote 3
            • L
              leinad last edited by

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

              1 Reply Last reply Reply Quote 0
              • L
                leinad last edited by

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

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