QT create a new class with an other in parameters

I m beginner in c++ with QT. I have a problem to instanciate a new class with an other in parameter..

My problem is to add in a QList Asteroids Object. In QT I have this error message:

cannot convert ‘SettingsAsteroid’ to ‘SettingsAsteroid*’ in assignment
this->settingsAsteroid = SettingsAsteroid();

I have show the .h and .c of the class who do it and the constructor of Asteroid.I think others class aren’t important.

Thx you to help a beginner in this language 🙂


Data in GameView.h

    #ifndef GAMEVIEW_H
    #define GAMEVIEW_H

    #include <QGraphicsView>
    #include <QGraphicsItem>

#include <QApplication>
#include <QPushButton>
#include <QList>
#include <QObject>
#include <QString>

#include "Asteroid.h"
#include "SettingsAsteroid.h"

class GameView : public QGraphicsView

    // Data
    int nbAsteroids;
    int nbAsteroidsAlive;
    SettingsAsteroid* settingsAsteroid;
    QList<Asteroid> asteroids;

    // Menu
    QPushButton *startgame;

    // Scène
    QGraphicsScene* grfxScene;


private slots:

    void start();


#endif // GAMEVIEW_H

Source code in GameView.c

#include "GameView.h"
#include <iostream>

    int nbAsteroids = 0;
    int nbAsteroidsAlive = 0;

    // data de jeu
    this->settingsAsteroid = SettingsAsteroid();

    //Scene de debut
    this->grfxScene = new QGraphicsScene();



GameView::~GameView(){ }

void GameView::start()

    int nbAsteroids = 4;
    int nbAsteroidsAlive = 4;

    int i;
    for(i=0;i<nbAsteroids;i++) {
       asteroids.append(new Asteroid(settingsAsteroid));

Constructor of Asteroid.c

Asteroid::Asteroid(SettingsAsteroid settingsAsteroid)

Source: c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.