QGraphicsView subclass fails



  • I am creating a subclass of QGraphicsView and promoting the GraphicsView widget to that subclass, MyView, using Qt5.10 under Mint Linux. Before I promote MyView, the item show, but when promoted it fails to display the items.

    #include <QObject>
    #include <QGraphicsView>
    class MyView : public QGraphicsView
    {
    Q_OBJECT
    public:
        MyView(QWidget *parent);
    };
    MyView::MyView(QWidget *parent)
    {}
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        QGraphicsScene *scene = new QGraphicsScene(QRect(0, 0, 1000, 1000), this);
        scene->setBackgroundBrush(Qt::yellow);
        ui->view->setScene(scene);
        scene->addItem(new RocketLauncher(this));
        scene->addLine(0, 0, 1000, 1000);
    }
    

    Any ideas as to where I can begin to solve this problem?



  • Found the Problem! The following is the fix:
    MyView::MyView(QWidget *parent) : QGraphicsView(parent)
    {}


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.