Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    How to acces MainWindow objects from QGraphicsItem

    General and Desktop
    2
    3
    2960
    Loading More Posts
    • 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
      apollo74 last edited by

      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 Reply Quote 0
      • G
        giesbert last edited by

        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 Reply Quote 0
        • A
          apollo74 last edited by

          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 Reply Quote 0
          • First post
            Last post