error: cannot initialize object parameter of type 'Ui_MainWindow' with an expression of type 'Ui::MainWindow'
-
What is the solution of this error? Can anybody help me in this? Thank you
#include "mainwindow.h" #include "ui_mainwindow.h" #include <iostream> #include <math.h> using namespace std; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_timerId(0), m_steps(0), m_realTime (0.0) { ui->setupUi(this); m_timerId = startTimer(0); m_time.start(); } MainWindow::~MainWindow() { cout << "Average time step: " << ( (double)m_realTime ) / ( (double)m_steps ) << " s" << endl; if ( m_timerId ) killTimer( m_timerId ); if ( ui ) delete ui; ui = 0; //delete ui; } void MainWindow::timerEvent(QTimerEvent *event) { QMainWindow::timerEvent(event); float timeStep = m_time.restart(); m_realTime = m_realTime + timeStep / 1000.0f; float roll = 0.0f; float pitch = 0.0f; if(ui->pushButtonAuto->isChecked()) { roll = 180.0f * sin( m_realTime / 10.0f ); pitch = 90.0f * sin( m_realTime / 20.0f ); ui->spinBoxRoll ->setValue( roll ); ui->spinBoxPitch ->setValue( pitch ); } else { roll = (float) ui->spinBoxRoll ->value(); pitch = (float) ui->spinBoxPitch ->value(); } // ui->widgetPFD->setRoll(roll); // ui->widgetPFD->setPitch(pitch); // ui->widgetSix->setRoll(roll); // ui->widgetSix->setPitch(pitch); m_steps++; }
-
@suslucoder
Which line is the error reported on? -
@suslucoder
Hover your mouse over thesetupUi
word/method. What does the signature report? It should bevoid Ui_MainWindow::setupUi(QMainWindow *MainWindow)
? Did you make changes to, say, theui_mainwindow.h
file? Delete all the files in the build output directory (i.e. debug/release depending on how you are building, where thatui_mainwindow.h
is) and rebuild from scratch? -
@suslucoder
What works? Do you mean the deleting of all intermediate files and rebuilding from scratch? -
@suslucoder
If you changed anything inui_mainwindow.h
this could happen. If you get what seems like an inexplicable error when compiling, wiping the output directory can sometimes resolve. However, this does not apply to normal, run-of-the-mill errors!