Errors in migrating from Qt5 to Qt6
-
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 -
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@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 -
@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