I would like to have a class member pointer static so that I can access it via classname::pointer.
In the following code titleLabel is a pointer to a QLabel that I would like to make static.
I get an error :-1: error: mainwindowii.o:(.bss+0x0): multiple definition of `ui::titlelabel'; main.o:(.bss+0x0): first defined here
#ifndef MAINWINDOWII_H
#define MAINWINDOWII_H
#include <QMainWindow>
#include <QLabel>
#include <QBoxLayout>
#include <QStyle>
#include <QDesktopWidget>
#include <QScreen>
class Game;
//class StateMachine;
namespace Ui {
class MainWindowII;
}
class MainWindowII : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindowII(QWidget *parent = nullptr);
~MainWindowII();
void setGame(Game *g);
Game *_pGame; // pointer to the game object
static QLabel *titleLabel; // label to show the title - probably morph this to use as general purpose image display
//QLabel *MainWindowII::titleLabel = new QLabel(); //nullptr_t; // new QLabel(this);
private slots:
void on_actionNew_Game_triggered();
private:
Ui::MainWindowII *ui;
void startNewGame();
void initTitle(); // load the title bitmap
};
QLabel * titlelabel = new QLabel();
#endif // MAINWINDOWII_H