connect actions to custom Qgraphicsview
Unsolved
General and Desktop
-
Hi, I am working on an app using QStackedWidgets.
The first widget is a login screen
the second widget is a drawing app
the drawing app contains a graphicsview that is promoted to a custom graphicsview.in my mainWindow I'd like to set the actions and some apply to the graphicsview.
I tried it like this, but it's not working because I create a new DrawingView instance instead of using the one that's loaded in the widget.
drawView = new DrawingView(); connect(ui->actionZoom_In, &QAction::triggered, drawView, &DrawingView::zoomIn); connect(ui->actionZoom_Out, &QAction::triggered, drawView, &DrawingView::zoomOut);
I also tried this:
drawView = qobject_cast<DrawingView*>(ui->stackedWidget->widget(1)->graphicsView); //also tried (ui->stackedWidget->widget(1)->ui->graphicsView) connect(ui->actionZoom_In, &QAction::triggered, drawView, &DrawingView::zoomIn); connect(ui->actionZoom_Out, &QAction::triggered, drawView, &DrawingView::zoomOut);
but that one gives an error on "ui->stackedWidget->widget(1)->graphicsView" or "ui->stackedWidget->widget(1)->ui->graphicsView"
please let me know how to fix this and also if it's not fixable or if you know any way how I can access the ui file of the MainWindow from my QWidget.
-
Hi,
What exactly is not working ?