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. connect actions to custom Qgraphicsview
Forum Updated to NodeBB v4.3 + New Features

connect actions to custom Qgraphicsview

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsviewqstackedwidgets
2 Posts 2 Posters 436 Views 2 Watching
  • 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.
  • H Offline
    H Offline
    hobbyProgrammer
    wrote on 22 Nov 2019, 11:16 last edited by hobbyProgrammer
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Nov 2019, 21:46 last edited by
      #2

      Hi,

      What exactly is not working ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      22 Nov 2019, 11:16

      • Login

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