Results 1 to 1 of 1

Thread: Slot connecting ordering issue vs properties

  1. #1
    Join Date
    Sep 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Slot connecting ordering issue vs properties

    Hi,

    I have developed a Qt Quick compatible Component in C++, that exposes properties and a signal. It seems the ordering of setting properties and connecting signals is not working for me. The component has a property where it's READ function within the C++ class could emit a signal. The issue seems to be though that the property value is being set before the signal from the class is connected, so because of this the receiving QML object doesn't receive the signal as it seems it's not connected yet.

    If I change the location where the property is set, say from an onClicked of a MouseArea component then the signal is received correctly.

    example:

    Qt Code:
    1. MsiInstaller{
    2.  
    3. id:msi
    4. msiFile: "installer.msi";
    5.  
    6. onException: {
    7. console.log("Exception thrown: code " + code);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    the msiFile property, when setting, can cause the exception signal to be thrown. But when done like the example above, the onException slot is not fired. If I comment out the msiFile line and set the property elsewhere, it works as expected.

    Is there a way to make sure the slots are connected before the properties are set.

    Thanks.


    Added after 14 minutes:


    I have altered it so that the property is not set until Component.onCompleted is fired. Is that the best approach? Thanks.
    Last edited by CCob; 22nd October 2011 at 12:52.

Similar Threads

  1. Replies: 2
    Last Post: 10th August 2011, 18:12
  2. Connecting signal and slot by name
    By grayfox in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2011, 09:00
  3. connecting issue with QAbstractItemModel
    By dave_mm0 in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2009, 14:01
  4. Connecting dynamically added properties
    By stefkeB in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2008, 15:19
  5. Connecting to a slot not within an Obejct
    By Matze-o in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 14:02

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.