[Qt-interest] problem with closeEvent
Israel Brewster
israel at frontierflying.com
Tue Mar 10 00:00:38 CET 2009
Try #including <QCloseEvent>
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
On Mar 9, 2009, at 1:49 PM, Knapp wrote:
> Hello, I am totally stumped. Why am I getting this error? What did I
> do wrong?
> Thanks!!
>
> The relevant error output.
>
> mainwindow.cpp: In member function ‘virtual void
> MainWindow::closeEvent(QCloseEvent*)’:
> mainwindow.cpp:38: error: invalid use of incomplete type ‘struct
> QCloseEvent’
> /opt/qtsdk-2009.01/qt/include/QtGui/qwidget.h:83: error: forward
> declaration of ‘struct QCloseEvent’
> mainwindow.cpp:40: error: invalid use of incomplete type ‘struct
> QCloseEvent’
> /opt/qtsdk-2009.01/qt/include/QtGui/qwidget.h:83: error: forward
> declaration of ‘struct QCloseEvent’
> mainwindow.cpp: In member function ‘bool MainWindow::save()’:
>
> header code:
>
> #ifndef MAINWINDOW_H
> #define MAINWINDOW_H
>
> #include <QtGui/QMainWindow>
> #include <QString>
> #include <QFile>
> #include <QTextStream>
> #include <QtXml>
> #include <QMessageBox>
> #include <QTranslator>
>
> namespace Ui
> {
> class MainWindowClass;
> }
>
> class MainWindow : public QMainWindow
> {
> QString thrust_Damage[55]; // cPickle.load(open('Thrust.p','rb'));
> QString swing_Damage[55]; // 55 is overkill just in case.
>
> int real_HP; // Hit Points
> int real_FP; // Fatugue Points
> int real_WILL; // Will
> int real_PER; // Perception
> double real_BS; //# BS Basic_Speed
> int real_BM; // # BM Basic_Move
>
> Q_OBJECT
>
> public:
> MainWindow(QWidget *parent = 0);
> ~MainWindow();
>
> protected:
> void closeEvent(QCloseEvent *event);
>
> CPP CODE!!!
>
> #include "mainwindow.h"
> #include "ui_mainwindow.h"
>
> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new
> Ui::MainWindowClass)
> {
>
> set_New();
>
> ui->setupUi(this);
> // the ST connection was done in the UI designer.
> connect(ui->spinBox_DX, SIGNAL(valueChanged(int)), this,
> SLOT(label_DX_Cost_Set(int)));
> connect(ui->spinBox_IQ, SIGNAL(valueChanged(int)), this,
> SLOT(label_IQ_Cost_Set(int)));
> connect(ui->spinBox_HT, SIGNAL(valueChanged(int)), this,
> SLOT(label_HT_Cost_Set(int)));
> connect(ui->spinBox_HP, SIGNAL(valueChanged(int)), this,
> SLOT(adjust_HP(int)));
> connect(ui->spinBox_FP, SIGNAL(valueChanged(int)), this,
> SLOT(adjust_FP(int)));
> connect(ui->spinBox_WILL, SIGNAL(valueChanged(int)), this,
> SLOT(adjust_WILL(int)));
> connect(ui->spinBox_PER, SIGNAL(valueChanged(int)), this,
> SLOT(adjust_PER(int)));
> connect(ui->lineEdit_Points_Total, SIGNAL(textChanged(QString)),
> this, SLOT(adjust_Unspent_Points()));
> connect(ui->doubleSpinBox_BS, SIGNAL(valueChanged(double)), this,
> SLOT(adjust_Basic_Speed(double)));
> connect(ui->spinBox_BM, SIGNAL(valueChanged(int)), this,
> SLOT(adjust_Basic_Move(int)));
> loadText(); // loads in thrust and swing damage data
> adjust_Unspent_Points();
> ui->lineEdit_Basic_Lift->setText(QString::number(ui->spinBox_ST-
> >value()
> * ui->spinBox_ST->value() / 5));
> ui->lineEdit_Thr->setText(thrust_Damage[10]);
> ui->lineEdit_Sw->setText(swing_Damage[10]);
> ui->lineEdit_Name->setFocus(Qt::OtherFocusReason); // a good place
> for the cursor to be at startup.
> }
>
> MainWindow::~MainWindow()
> {
> delete ui;
> }
>
> void MainWindow::closeEvent(QCloseEvent *event)
> {
> if (okToContinue()) {
> writeSettings();
> event->accept();
> } else {
> event->ignore();
> }
> }
> --
> Douglas E Knapp
>
> Why do we live?
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list