Results 1 to 4 of 4

Thread: Signal/Slots across different files--help needed

  1. #1
    Join Date
    Oct 2006
    Posts
    75
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Signal/Slots across different files--help needed

    hi ppl,
    this issue might be addressed before, but i did not find right solution. in my application i am using one file(ex..mainwindow.cpp) for gui drawing and some other files for accessing and controlling gui. if the signals r generated in mainwindow.cpp (gui file) they should be accessed in the control files and vice versa.. how can i do that. guys, pls help in this regard. iam giving the outline of my application.

    // 1. main.cpp
    #include "mainwindow.h"
    main
    {
    create mainwindow object and show. // its the gui window
    }

    // 2. mainwindow.cpp
    #include "mainwindow.h"
    {
    create gui window and display.
    setup signals for window widgets and their corresponding slots.
    }

    // 3. controller1.cpp
    {
    catch signals from mainwindow.cpp and do some controller activities.
    emit signals for mainwindow.cpp and to be used to perform gui activities.
    }

    i might not explain the outline properly, but the idea is to access signals and slots of one file(rather class) from other file(class) and vice versa..
    pls put some light on to this topic and suggest me solutions..thank u.

  2. #2
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Signal/Slots across different files--help needed

    whtever I understood, you should use an object of that class into different class to access its signal .....
    you can also use flag to emit signal on that particuler event.....

  3. #3
    Join Date
    Oct 2006
    Posts
    75
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Signal/Slots across different files--help needed

    thanks shahi,
    i got the solution from one article on net.. what ever u suggested was the same thing that i tried. thank u very much for ur reply..by the way, QSharedMemory is available only from Qt 4.4 onwards? i think sharedmemory is the best way to share data among objects..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal/Slots across different files--help needed

    Quote Originally Posted by swamyonline View Post
    by the way, QSharedMemory is available only from Qt 4.4 onwards?
    Yes.

    Quote Originally Posted by swamyonline View Post
    i think sharedmemory is the best way to share data among objects..
    Shared memory is an inter-process communication mechanism. You don't need it to pass data between objects whithin a single process. It would be like using a corkboard in the hall to talk to a friend that sits besides you.

Similar Threads

  1. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05
  2. Replies: 5
    Last Post: 22nd September 2006, 08:04
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.