This is the line of code that breaks when I moved my project from QT 5.12 to QT 5.15.
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
The error that is thrown is the following:
mainwindow.cpp:28:5: error: cannot initialize object parameter of type 'QWidget' with an expression of type 'MainWindow'
I am doing this migration because QT recommends moving to 5.15 before moving to QT 6. I have tried doing it the following way as well but gives me the same error.
Qt::WindowFlags flags;
flags |= Qt::Window;
flags |=Qt::FramelessWindowHint;
setWindowFlags(flags);
Here is the code for the whole MainWindow constructor there are several more errors in it as well, but for now lets focus on this one.
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
translator.load("://languages/translation_en.qm");
qApp->installTranslator(&translator);
//Initial UI setup.
#ifndef DESKTOP
/*
Qt::WindowFlags flags;
flags |= Qt::Window;
flags |=Qt::FramelessWindowHint;
setWindowFlags(flags);
*/
setWindowFlags(Qt::Window | Qt::FramelessWindowHint); //this is the line in question
setWindowState(Qt::WindowFullScreen);
#endif
ui->setupUi(this);
ui->remoteStatus->setVisible(false);
ui->simpleRemoteStatus->setVisible(false);
ui->simpleFrame->hide();
ui->dashboardFrame->hide();
ui->childFrame->hide();
startButtonDown = ui->simpleStartButton->isChecked();
stopButtonDown = ui->simpleStopButton->isChecked();
setupIcons();
//
double hmiver = 380;//version number
#ifdef CYCLE
hmiver = 999;
#endif
//Setup for Modbus Slave
thread = new QThread(this);
data = new DataThread();
data->moveToThread(thread);
connect(thread, SIGNAL(started()), data, SLOT(runProcess()));
//
setupMenus();
comsMod->RetainedData.HMIVer = hmiver;
comsMod->RTData.HMIVer = hmiver;
settingsMenu->aboutMenu->setHMIVer(hmiver);
setupTimers();
connectAll();
//Starts RTM communications on device side
DisplayCountTimer->setInterval(100);
DisplayCountTimer->start();
//After 2 seconds, starts remaining processes
StartModbusTimer->setInterval(2000);
StartModbusTimer->start();
/* Used for cycle testing */
#ifdef USBTEST
usbTest();
#endif
/* Used for cycle testing */
#ifdef CYCLE
this->on_productionButton_clicked();
#endif
}
I am working on Ubuntu 20.04
I suspect that you switched to Qt 5.15 but you are trying to build the project in the same directory as you did with 5.12. And the cause of your problems is that some build files remained there after the old compilation. Mixing build files from two different Qt versions in the same directory is a 100 % recipe for disaster.
Therefore it also reports wrong row. I am almost certain that the problematic row is actually this:
ui->setupUi(this);instead of thissetWindowFlags(Qt::Window | Qt::FramelessWindowHint);.I strongly advice for having two separate build directories. One for each version.
Or, if you want just one build directory for some strange reason, then always delete the contents of the previous build. Or at least try re-running qmake and try complete rebuild, but this may sometimes not work well. It is just more certain to delete all stuff from the build with the prevous version.