#ifndef FLAGOBJECT_H#define FLAGOBJECT_H#include <QByteArray>#include <QMap>#include <QString>#include <QVector>class QImage;class QColor;class FlagObject{public: static FlagObject *instance; static FlagObject* getInstance() { if(!instance) instance = new FlagObject(); return instance; } ~FlagObject(); void getFlag(int flagNum, QImage &image);private: FlagObject(); bool openDatFile(QString fileName); int m_FlagCount; QVector<QColor> *m_FlagBuffer; QMap<int, QString> *m_ColorMap; void init_ColorMap() { m_ColorMap = new QMap<int, QString>; m_ColorMap->insert(0, "black"); m_ColorMap->insert(1, "darkRed"); m_ColorMap->insert(2, "darkGreen"); m_ColorMap->insert(3, "darkYellow"); m_ColorMap->insert(4, "darkBlue"); m_ColorMap->insert(5, "darkMagenta"); m_ColorMap->insert(6, "darkCyal"); m_ColorMap->insert(7, "darkGray"); m_ColorMap->insert(8, "lightGray"); m_ColorMap->insert(9, "red"); m_ColorMap->insert(10, "green"); m_ColorMap->insert(11, "yellow"); m_ColorMap->insert(12, "blue"); m_ColorMap->insert(13, "magenta"); m_ColorMap->insert(14, "cyan"); m_ColorMap->insert(15, "white"); }};#endif // FLAGOBJECT_H
#include "flagviewdelegate.h"#include "flagobject.h"FlagViewDelegate::FlagViewDelegate(QObject *parent) : QItemDelegate(parent){}void FlagViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ FlagObject *flagObject = FlagObject::getInstance();}
FlagObject *FlagObject::instance = NULL;
#include "mainwindow.h"#include "ui_mainwindow.h"#include "testsingle.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); TestSingle *t = TestSingle::getInstance(); // Ошибка в этой строке.}MainWindow::~MainWindow(){ delete ui;}
C++ (Qt)public: static FlagObject *instance;
class FlagObject;