qt6 migration issue
-
@JonB Can it be related to the error message on the top of the editor window?
Stating:
Error:Could not decode "colorrange.cpp" with "UTF-8"-encoding. Editing not possible. -
@Actarus
That's not good! There would appear to be a problem if editor says the.cpp
is not editable I would be worried :) Which may lead to a problem when trying to compile it to the.o
file.... -
@Actarus
That's not good! There would appear to be a problem if editor says the.cpp
is not editable I would be worried :) Which may lead to a problem when trying to compile it to the.o
file.... -
@JonB I've just checked and I have the same message on the other PC with QT5 but, in that case, it compiles without errors and I can find the colorrange.o file in the debug folder.
-
@Actarus
I would delete thedebug
folder and do a full, clean rebuild from scratch. If it errors look carefully at the compile output, because what you show seems "strange".@JonB Did it but it didn't change, but the colorrange.cpp file is "casually" the same where I have the error mentioned above about backgroundcolor that is the last one code issue that had not yet been corrected.
Could you please give me a tip about it and maybe it fixes also the Error1?
"Can you help in correcting the sintax for QT6 for the following line of QTableWidgetItem:
colorPicker = new QColorDialog(ui->table->item(r, 0)->backgroundColor(), nullptr
I corrected replacing backgroundColor with background, but I can't get the correct sintax."
Thanks.
-
@JonB Did it but it didn't change, but the colorrange.cpp file is "casually" the same where I have the error mentioned above about backgroundcolor that is the last one code issue that had not yet been corrected.
Could you please give me a tip about it and maybe it fixes also the Error1?
"Can you help in correcting the sintax for QT6 for the following line of QTableWidgetItem:
colorPicker = new QColorDialog(ui->table->item(r, 0)->backgroundColor(), nullptr
I corrected replacing backgroundColor with background, but I can't get the correct sintax."
Thanks.
-
@Actarus
The line you show simply seems to be missing the trailing);
. Other than that I don't think it has changed from Qt5. If you get an error copy & paste exactly what the compiler shows you about it.@JonB Sorry, just didn't pasted here the ); but it's in the code.
Actually in QT6 it's no longer possible to use 'backgroundColor', indeed I replaced it with 'background' in all the other situations where I had the same error message and it worked.The error text is the following:
error: 'class QTableWidgetItem' has no member named 'backgroundColor'; did you mean 'background'?
307 | colorPicker = new QColorDialog(ui->table->item(r, 0)->backgroundColor(), nullptr/ui->table/);
| ^~~~~~~~~~~~~~~
| backgroundBut replacing it with 'background', then I get the message :
colorrange.cpp:307:27: No matching constructor for initialization of 'QColorDialog'
qcolordialog.h:36:14: candidate constructor not viable: no known conversion from 'QBrush' to 'const QColor' for 1st argument
qcolordialog.h:35:14: candidate constructor not viable: allows at most single argument 'parent', but 2 arguments were provided
:74:20: note: candidate constructor not viable: requires 1 argument, but 2 were provided -
@Actarus
The line you show simply seems to be missing the trailing);
. Other than that I don't think it has changed from Qt5. If you get an error copy & paste exactly what the compiler shows you about it. -
@Actarus
The line you show simply seems to be missing the trailing);
. Other than that I don't think it has changed from Qt5. If you get an error copy & paste exactly what the compiler shows you about it.@JonB Jon, now that I fixed all the errors, if I compile I suddenly get around 1600 errors like the following one but in QT5 it has always compiled and run perfectly.
error: conversion from 'const char [2]' to 'QChar' is ambiguous
: conversion from 'const char [2]' to 'QChar' is ambiguous
933 | if(formula.at(i) == "'" && i+1 < formula.length())
| ^~~Invalid operands to binary expression ('const QChar' and 'const char[2]')
qchar.h:582:34: candidate function not viable: no known conversion from 'const char[2]' to 'QChar' for 2nd argumentHere the code:
QString can; for(int i = 0; i < formula.size(); i++) { if(formula.at(i) == "'" && i+1 < formula.length()) { i += 1; while(i < formula.length() && formula.at(i) != "'") { can.append(formula.at(i)); i += 1; } if(cBoxChannel_1->findText(can) != -1) { nChannels += 1; if(nChannels == 1) cBoxChannel_1->setCurrentIndex(cBoxChannel_1->findText(can)); else if(nChannels == 2) cBoxChannel_2->setCurrentIndex(cBoxChannel_2->findText(can)); else if(nChannels == 3) cBoxChannel_3->setCurrentIndex(cBoxChannel_3->findText(can)); else if(nChannels == 4) cBoxChannel_4->setCurrentIndex(cBoxChannel_4->findText(can)); else if(nChannels == 5) cBoxChannel_5->setCurrentIndex(cBoxChannel_5->findText(can)); else if(nChannels == 6) cBoxChannel_6->setCurrentIndex(cBoxChannel_6->findText(can)); else if(nChannels == 7) cBoxChannel_7->setCurrentIndex(cBoxChannel_7->findText(can)); else if(nChannels == 8) cBoxChannel_8->setCurrentIndex(cBoxChannel_8->findText(can)); } can.clear(); } }
The claimed part is the ==:
if(formula.at(i) == "'" && i+1 < formula.length())
-
@JonB Jon, now that I fixed all the errors, if I compile I suddenly get around 1600 errors like the following one but in QT5 it has always compiled and run perfectly.
error: conversion from 'const char [2]' to 'QChar' is ambiguous
: conversion from 'const char [2]' to 'QChar' is ambiguous
933 | if(formula.at(i) == "'" && i+1 < formula.length())
| ^~~Invalid operands to binary expression ('const QChar' and 'const char[2]')
qchar.h:582:34: candidate function not viable: no known conversion from 'const char[2]' to 'QChar' for 2nd argumentHere the code:
QString can; for(int i = 0; i < formula.size(); i++) { if(formula.at(i) == "'" && i+1 < formula.length()) { i += 1; while(i < formula.length() && formula.at(i) != "'") { can.append(formula.at(i)); i += 1; } if(cBoxChannel_1->findText(can) != -1) { nChannels += 1; if(nChannels == 1) cBoxChannel_1->setCurrentIndex(cBoxChannel_1->findText(can)); else if(nChannels == 2) cBoxChannel_2->setCurrentIndex(cBoxChannel_2->findText(can)); else if(nChannels == 3) cBoxChannel_3->setCurrentIndex(cBoxChannel_3->findText(can)); else if(nChannels == 4) cBoxChannel_4->setCurrentIndex(cBoxChannel_4->findText(can)); else if(nChannels == 5) cBoxChannel_5->setCurrentIndex(cBoxChannel_5->findText(can)); else if(nChannels == 6) cBoxChannel_6->setCurrentIndex(cBoxChannel_6->findText(can)); else if(nChannels == 7) cBoxChannel_7->setCurrentIndex(cBoxChannel_7->findText(can)); else if(nChannels == 8) cBoxChannel_8->setCurrentIndex(cBoxChannel_8->findText(can)); } can.clear(); } }
The claimed part is the ==:
if(formula.at(i) == "'" && i+1 < formula.length())
error: conversion from 'const char [2]' to 'QChar' is ambiguous
: conversion from 'const char [2]' to 'QChar' is ambiguousWe already discussed this problem ...
-
error: conversion from 'const char [2]' to 'QChar' is ambiguous
: conversion from 'const char [2]' to 'QChar' is ambiguousWe already discussed this problem ...
@Christian-Ehrlicher Thanks, fixed.
I'm facing a couple of situations that in QT5 compile without problem but not in QT6:
connect(xychart->m_ChartViewer, &QChartViewer::needTrackLineXYChart, this, &AnalysisWindow::trackLineAxis);
and
connect(m_ChartViewer, &QChartViewer::MouseIsPressed, this, &BaseViewPortComp::mousePressEvent);
In both cases the problem is error:
static assertion failed: Signal and slot arguments are not compatible.
214 | static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),I assume it's because it's not possible to connect a QPointerEvent to a QMouseEvent, but how to get out of this?
-
@Christian-Ehrlicher Thanks, fixed.
I'm facing a couple of situations that in QT5 compile without problem but not in QT6:
connect(xychart->m_ChartViewer, &QChartViewer::needTrackLineXYChart, this, &AnalysisWindow::trackLineAxis);
and
connect(m_ChartViewer, &QChartViewer::MouseIsPressed, this, &BaseViewPortComp::mousePressEvent);
In both cases the problem is error:
static assertion failed: Signal and slot arguments are not compatible.
214 | static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),I assume it's because it's not possible to connect a QPointerEvent to a QMouseEvent, but how to get out of this?
Qt has no class named
QChartViewer
so I don't know this class. Most likely the signature of the signals changed so you have to adjust your slots accordingly - normal developer stuff. -
Qt has no class named
QChartViewer
so I don't know this class. Most likely the signature of the signals changed so you have to adjust your slots accordingly - normal developer stuff.@Christian-Ehrlicher Thanks Christian, fixed adjusting slots.