No, I don't use threads. I tried it as a work-around, but got stuck there too. Also seemed to be too complicated for what I need.
Here is some code to illustrate things :
.h file :
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
#include "OctoObject.h"
class OctoNormalise;
{
Q_OBJECT
public:
MainWindow
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~MainWindow();
private:
OctoNormalise* normalise;
//All static objects to allow for the use of the static callback function
static void _stdcall errorHandler(OctoObject::error_code error);
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
#include "OctoObject.h"
class QErrorMessage;
class OctoNormalise;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
~MainWindow();
private:
OctoNormalise* normalise;
//All static objects to allow for the use of the static callback function
static QErrorMessage* errorMessage;
static void _stdcall errorHandler(OctoObject::error_code error);
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
.cpp file :
#include "QTGUI"
#include "mainwindow.h"
#include "OctoNormalise.h"
MainWindow
::MainWindow(QWidget *parent, Qt
::WFlags flags
){
//Create the QErrorMessage Object
//Set the error handler
OctoObject::setErrorHandler(&MainWindow::errorHandler);
//Create an object from the SDK as a test (this force the generation of several errors the way it is done now)
normalise = new OctoNormalise;
}
void __stdcall MainWindow::errorHandler(OctoObject::error_code error)
{
//Select the dialog text based on the error coming from the SDK
switch (error)
{
case OctoObject
::HaspErr : errorMessage
->showMessage
(QString("No valid HASP key available"));
break;
case OctoObject
::FileOpenErr : errorMessage
->showMessage
(QString("File could not be found/opened"));
break;
// ...
}
}
MainWindow::~MainWindow()
{
//Delete all used objects
delete normalise;
delete errorMessage;
//Resets the error handler to a dummy function (not actually NULL, this is implemented in the SDK to be handled safely)
OctoObject::setErrorHandler(NULL);
}
#include "QTGUI"
#include "mainwindow.h"
#include "OctoNormalise.h"
QErrorMessage* MainWindow::errorMessage = 0;
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
//Create the QErrorMessage Object
errorMessage = new QErrorMessage;
//Set the error handler
OctoObject::setErrorHandler(&MainWindow::errorHandler);
//Create an object from the SDK as a test (this force the generation of several errors the way it is done now)
normalise = new OctoNormalise;
}
void __stdcall MainWindow::errorHandler(OctoObject::error_code error)
{
//Select the dialog text based on the error coming from the SDK
switch (error)
{
case OctoObject::HaspErr : errorMessage->showMessage(QString("No valid HASP key available")); break;
case OctoObject::FileOpenErr : errorMessage->showMessage(QString("File could not be found/opened")); break;
// ...
}
}
MainWindow::~MainWindow()
{
//Delete all used objects
delete normalise;
delete errorMessage;
//Resets the error handler to a dummy function (not actually NULL, this is implemented in the SDK to be handled safely)
OctoObject::setErrorHandler(NULL);
}
To copy to clipboard, switch view to plain text mode
Bookmarks