Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsView subclass fails

QGraphicsView subclass fails

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 483 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ofmrew
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • O Offline
      O Offline
      ofmrew
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved