Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

add a textedit widget to a graphics view scene



  • Hello,
    I am a newbie to qt. I was trying to add a text edit widget to a scene such that it occupies the entire viewport of the graphicsview(just want to give user some space to add some text). I am stuck here and also a bit confused in coordinate conversions. below is a sample code. Thanks for any help in advance.

        QGraphicsScene *scene=new QGraphicsScene();
        ui->graphicsView->setScene(scene);
        ui->graphicsView->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    
        QTextEdit *notes=new QTextEdit(this);
        notes->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        notes->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        notes->setPlaceholderText("Notes");
        notes->setStyleSheet("QTextEdit{ border: 2px solid black;}");
    //    notes->setGeometry(0,20,800,500);
        QGraphicsProxyWidget *proxy = scene->addWidget(notes);