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. Errors in migrating from Qt5 to Qt6
Qt 6.11 is out! See what's new in the release blog

Errors in migrating from Qt5 to Qt6

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 462 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
    Actarus
    wrote on last edited by
    #1

    Hello,
    I'm new to developing and Qt, I need to migrate an existing project to Qt6 and modified several parts of code succesfully, but now I'm facing the following issue because of the deprecated backgroundColor member:

    QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->backgroundColor().red())); 
    tagRed.appendChild(txtRed);
    

    This is the code after replacing backgroundColor with background

    QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->setBackground(Qt::red)));
    tagRed.appendChild(txtRed);
    

    This solved the error but I got a new one for that line that now says: No matching function for call to 'number'.

    Is that the correct way to replace that deprecated member?

    Thanks.

    OS: Windows 11
    Qt: 6.4.3

    JoeCFDJ 1 Reply Last reply
    0
    • A Actarus

      Hello,
      I'm new to developing and Qt, I need to migrate an existing project to Qt6 and modified several parts of code succesfully, but now I'm facing the following issue because of the deprecated backgroundColor member:

      QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->backgroundColor().red())); 
      tagRed.appendChild(txtRed);
      

      This is the code after replacing backgroundColor with background

      QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->setBackground(Qt::red)));
      tagRed.appendChild(txtRed);
      

      This solved the error but I got a new one for that line that now says: No matching function for call to 'number'.

      Is that the correct way to replace that deprecated member?

      Thanks.

      OS: Windows 11
      Qt: 6.4.3

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @Actarus said in Errors in migrating from Qt5 to Qt6:

      ui->table->item(i,0)->setBackground(Qt::red)

      ui->table->item(i,0)->setBackground(Qt::red) is func call, but not a number.

      ui->table->item(i,0)->backgroundColor().red() is a number.

      You may change it to
      QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->background().color().red()));
      from here
      https://doc.qt.io/qt-6/qtablewidgetitem.html#background

      A 1 Reply Last reply
      1
      • JoeCFDJ JoeCFD

        @Actarus said in Errors in migrating from Qt5 to Qt6:

        ui->table->item(i,0)->setBackground(Qt::red)

        ui->table->item(i,0)->setBackground(Qt::red) is func call, but not a number.

        ui->table->item(i,0)->backgroundColor().red() is a number.

        You may change it to
        QDomText txtRed = xmlDoc.createTextNode(QString::number(ui->table->item(i,0)->background().color().red()));
        from here
        https://doc.qt.io/qt-6/qtablewidgetitem.html#background

        A Offline
        A Offline
        Actarus
        wrote on last edited by
        #3

        @JoeCFD said in Errors in migrating from Qt5 to Qt6:

        background().color().red()));

        Thanks Joe, indeed that worked!

        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