Rotating widget

  • I try to rotate widget^ but it is not work^ what I am doing wrong^ and how i can fix that?

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QApplication>
    #include <QLineEdit>
    #include <QGraphicsScene>
    #include <QGraphicsProxyWidget>
    #include <QGraphicsView>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
       // QPushButton *bouton = new QPushButton("Mon bouton entre en scène !");
              QGraphicsScene scene;
              QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget();
              scene.setSceneRect(-150, -150, 300, 300);
              QGraphicsView view(&scene);
        delete ui;

  • Lifetime Qt Champion

    @sashapont said:

    I assume, you see absolutely nothing?

    You define your scene as
    QGraphicsScene scene;
    which means its DELETED as soon as mainwindow constructor ends.

    same with your view
    QGraphicsView view(&scene);

    also gone as soon as constructor ends. Which is before the window is even shown.

    you should use new and pointer so they can live longer, or you put them in the class.
    or both :)

Log in to reply

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