Hi Qt pips,
I'm working with subdirectory project which has 3 subprojects.
Now, I'm having a problem calling the instance of a project to another project.
Here's the code of the header file of project1:
#if !defined(__TRIAL_H__)
#define __TRIAL_H__
#include <qwidget.h>
#include "TrialGlobal.h"
namespace Ui {
class Trial;
}
class TRIALSHARED_EXPORT Trial : public QWidget
{
Q_OBJECT
public:
explicit Trial (QWidget *Parent = 0);
~Trial (void);
Trial *get_instance();
private:
Ui::Trial *Ui;
};
#endif // __TRIAL_H__
source file:
#include <qapplication.h>
#include <qplastiquestyle.h>
#include "Trial.h"
#include "ui_Trial.h"
Trial::Trial (QWidget *Parent) :
QWidget(Parent),
Ui(new Ui::Trial)
{
Ui->setupUi(this);
return;
}
Trial::~Trial (void)
{
delete Ui;
return;
}
Trial *Trial::get_instance()
{
static CAbout TrialInstance;
return &TrialInstance;
}
When trying to instantiate that to project2 using this code:
Trial *newab = Trial::get_instance();
newab->show();
This generates this error:
cannot call member function 'Trial *Trial::get_instance()' without object
Second thing was can I instantiate this without using any static function or static declarations?
Thanks in advance guys.
Bookmarks