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. How to acces MainWindow objects from QGraphicsItem
Forum Updated to NodeBB v4.3 + New Features

How to acces MainWindow objects from QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k Views 1 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.
  • A Offline
    A Offline
    apollo74
    wrote on last edited by
    #1

    Hello again,

    I have an application where my main window contains a toolbar with buttons on it, a left menu QFrame with QLabel objects, and a central area of type QGraphicsScene where I drag and drop QGraphicsItems. Each one of those QGraphicsItems has an object of type QDialog that shows up when double clicking on the Item... when the dialog appears it contains a QGLWidget that will plot a mathematical function of mine (and here is my problem...) only when the button "Run" located in the toolbar of the MainWindow is clicked.
    So my question is, how do I read the status of the button "Run" located in the toolbar of the main window from within the dialog of a QGraphicsItem?

    Thanks for your suggestions,

    Boris

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      You could use some global status cache, or signals and slots to set the state from run button via MainWindow to the objects.

      Please do yourself a favor and don't try to access the button from the dialogs.

      I would use:

      run button connect to a slot in MainWindow and state stored there.

      give dialog a pointer to the main window and call a getter method there.

      Or create a custom QApplication derived class and store the state there. The global QApplication object can be used from all obejcts.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        apollo74
        wrote on last edited by
        #3

        Hi Gerolf,

        thanks for the tips, I like number 1, seems easy to do and I thought about that before but still my problem was how to read the state of "run" button stored in MainWindow from inside a dialog class of a QGraphicsItem inside a QGraphicsScene. Can you give me some help there too? Thanks.

        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