I'm trying to compile a QDialog cpp file that was working before, but now refuses to compile. I even replaced it and the .h with files that came from a default QDialog, but I keep getting these errors:
invalid use of incomplete type 'struct Ui::Dialog'
forward declaration of 'struct Ui::Dialog'
and in Visual Studio:
error C2512: 'Ui::Dialog' : no appropriate default constructor available
Code is below. Anyone know what's wrong here? I'm completely baffled.
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
Q_OBJECT
public:
~Dialog();
protected:
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog {
Q_OBJECT
public:
Dialog(QWidget *parent = 0);
~Dialog();
protected:
void changeEvent(QEvent *e);
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H
To copy to clipboard, switch view to plain text mode
#include "dialog.h"
#include "ui_dialog.h"
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks