Results 1 to 10 of 10

Thread: form and its objects communication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: form and its objects communication

    Don't check the status of the listbox in mouse events of another widget. Use signals and slots to connect to changes in the listbox's state (i.e. signals emitted by its QItemSelectionModel) to set a flag in your scene that the listbox has an item selected or not. Then just check this flag in the event. Same goes for updating the status bar - emit a signal from your scene with the new coordinates and connect it to a slot in your widget where you will update the status bar.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: form and its objects communication

    I get it that I can use signals and slots to do the trick. The problem here is disp can see the mapscene (custom graphicsScene) object and therefore it can use the signals produce by that object. I have use this to update the position of the mouse.

    However, since no reference of disp in mapscene, I can't see the signals emited by disp and hence wasn't able to reference to the signal from disp to notify mapscene that an item in the listbox is selected. This is the problem I am facing now.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: form and its objects communication

    What is "disp"? If that's an object of some kind then the answer is that you need to connect signals and slots from an object that sees both the source and target objects (which is most often the first common ancestor object of the two objects in question). If there is no such object then you can always relay (propagate) signals to the environment until a situation I described occurs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: form and its objects communication

    I manage to get it through by using pointers. Thanks for your help.

Similar Threads

  1. Pass variable from a form to another form
    By dark1988 in forum Qt Programming
    Replies: 5
    Last Post: 8th February 2011, 18:19
  2. Replies: 3
    Last Post: 9th January 2010, 15:47
  3. Help me to load one form over another form PushButton
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2008, 16:11
  4. Hiding a form and opening another form
    By anafor2004 in forum Newbie
    Replies: 1
    Last Post: 20th February 2008, 15:04
  5. Replies: 7
    Last Post: 18th July 2006, 21:33

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
  •  
Qt is a trademark of The Qt Company.