Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania bez odpowiedzi
Viewing all articles
Browse latest Browse all 21942

Qt - globalny wskaźnik na grę

$
0
0

Cześć, czy jest jakaś alternatywa dla globalnego wskaźnika gry w Qt? Próbowałem użyć singleton w ten sposób:

class Game : public QGraphicsView
{
    Q_OBJECT
private:
    Game(int width = 1024, int height = 768, QWidget * /*parent*/ = nullptr);
    static Game * game;

    QGraphicsScene * scene;

public:
    static Game * getInstance(int width = 1024, int height = 768, QWidget * parent = nullptr);
};
Game * Game::game = nullptr;

Game *Game::getInstance(int width, int height, QWidget * parent)
{
    if(game == nullptr)
        game = new Game(width, height, parent);
    return game;
}

Niestety nie mogę wtedy np. dodać nowych elementów do sceny(program się crashuje). Czy pozostaje mi jedynie globalny wskaźnik?


Viewing all articles
Browse latest Browse all 21942

Trending Articles


1


uszkodzony (zatarty?) silnik


Peugeot 508 problem z elektroniką


Alawar Keygen POLECAM


Kombajn ziemniaczany GRIMME HLS 750


POTANIACZ


Sok malinowy


Kasowanie inspekcji Hyundai ix35


Instrukcje Polskie do Transceiverów - wymiana


Steel Division 2 SPOLSZCZENIE