Results 1 to 3 of 3

Thread: Communication with multiple MDI widgets

  1. #1
    Join Date
    Jul 2017
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Communication with multiple MDI widgets

    Hey guys, i'm new to the forum and fairly new to QT. I have been using it on and off for more than a year and i have came to the following problem that i have not been able to pass.
    I have a main window with an MDI are and several child widget that are created in that are. Each one of the widget represent a circuit which I'm monitoring the voltage. The widgets are created by a loop when the main window is initialized. How can i talk to each child?

  2. #2
    Join Date
    Jul 2017
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Communication with multiple MDI widgets

    In case anyone is interested. I solved the problem, maybe crude and they maybe other solutions out there but here is how i did it.

    The main window updates a data class constantly, i have each of the child widget using a timer reading data from the data class. Works pretty well.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Communication with multiple MDI widgets

    The more Qt way of doing this is to derive the data class from QObject and implement a "dataUpdated()" signal for it. Each time the main window changes the data class, the data class emits this signal.

    Every child window has a "dataUpdate()" slot. When the main window creates the child windows, it connects this slot to the data class signal. In the child window slot, you do whatever you do to update the child's display.

    No need for timers or anything of the sort. The child windows update themselves only when necessary, not according to some arbitrary timeout signal which might cause them to miss new data (if the timeout is too long) or update themselves unnecessarily (if the timeout is too short).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 2nd October 2012, 01:38
  2. QScrollArea containing multiple widgets
    By Mercurial in forum Newbie
    Replies: 3
    Last Post: 4th February 2011, 10:08
  3. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  4. multiple Opengl Widgets:
    By manmohan in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2009, 05:06
  5. Data communication between multiple computers
    By AlbertGoodwill in forum Newbie
    Replies: 2
    Last Post: 8th October 2007, 13:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.