Results 1 to 4 of 4

Thread: tackling multiple forms object

  1. #1
    Join Date
    Jan 2010
    Posts
    39
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default tackling multiple forms object

    Hi all,

    I have 2 forms say f1, f2. f1 calls (loads) f2;

    I want to pass some content from f1 to f2. Do I create a public function which pass the data or is there some other way?
    eg. f1 text to f2 label.

    f2.h
    Qt Code:
    1. public:
    2. ...
    3. void f2_label_set_Text();
    4. ....
    To copy to clipboard, switch view to plain text mode 

    In f2, I got a custom GraphicsView with custom mousePressEvent. How can I ref to and object in f2 inside mousePressEvent of the custom GraphicsView?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: tackling multiple forms object

    There are several ways you can do this.
    You can use signals and slot.
    You can pass f2 to your custom GraphicsView.
    It depends on the general design of your application and the requirements which method is better for you.

    But this sort of question has nothing to do with Qt, but rather with basic C++ programming.
    I suggest you read and learn C++, then questions like this one wont come up any more.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2010
    Posts
    39
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: tackling multiple forms object

    I manage to pass the info by using set and get method but I still don't know how to pass info between custom object and its caller.

    ie

    f1 contains custom object
    custom object has a mousePressEvent which needs to check if f1's variable satisfy a condition.

    eg f1 has int i and calls a view (custom object of QGraphicsview)
    if i = 10 then do whenever things is in mousePressEvent.

    How to work this out?

  4. #4
    Join Date
    Jan 2010
    Posts
    39
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: tackling multiple forms object

    redirected to http://www.qtcentre.org/threads/2761...-communication with a more proper and clear title

Similar Threads

  1. Multiple Forms Handling
    By eva2002 in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2010, 06:24
  2. Multiple Forms and vertical layout in forms
    By eva2002 in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 05:05
  3. Multiple start() on same QThread Object
    By mdecandia in forum Qt Programming
    Replies: 4
    Last Post: 3rd November 2009, 08:14
  4. Handling multiple forms
    By msmihai in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 13:41
  5. PyQt - Mapping multiple forms to a database
    By peterjb31 in forum Qt Programming
    Replies: 4
    Last Post: 2nd May 2008, 21:31

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.