×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    3

    Question QML: disconnect signal object from all slots from QML

    Hi all!
    I can't find full documentation of QML disconnect method.

    I use next method to connect signal of "my button" to slots dynamically . Simultaneously I need only one connected slots, so another slots should be disconnected. In my application when i connect "new" slot to button, i need disconnect all "old" slots. But i can't find any API to do this.

    Something like this:

    Code:
    button.clicked.disconnect();
    does not work. I need make disconnection manually:
    Code:
    button.clicked.disconnect(obj.slot);
    It's very inconvenient. Is there some possibility make what i want? if need i can post part of source code.
    Thank you!

  2. #2
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    Re: QML: disconnect signal object from all slots from QML

    Code:
    SelectionDialog {
        id: selectionDialog
    }
    
    Button {
        id: btnFirst
        
        property int selectedIndex: 0
        
        onClicked: {
            selectionDialog.model = 10
            selectionDialog.selectedIndex = selectedIndex
            selectionDialog.accepted.connect(callback)
            selectionDialog.open()
        }
        
        function callback() {
            //selectionDialog.accepted.disconnect(callback)
            selectedIndex = selectionDialog.selectedIndex
            console.log("First:", selectedIndex)
        }
    }
    
    Button {
        id: btnSecond
        
        property int selectedIndex: 0
        
        onClicked: {
            selectionDialog.model = 4
            selectionDialog.selectedIndex = selectedIndex
            selectionDialog.accepted.connect(callback)
            selectionDialog.open()
        }
        
        function callback() {
            //selectionDialog.accepted.disconnect(callback)
            selectedIndex = selectionDialog.selectedIndex
            console.log("Second:", selectedIndex)
        }
    }
    Last edited by NooM; 2012-03-07 at 02:47.

Similar Threads

  1. Open default browser from qml
    By CristianL in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2011-08-12, 17:12
  2. How to call/load another QML file from QML ?
    By cadlg in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-07-28, 09:15
  3. [Qt QML] Questions regarding QML Performance
    By SeanZhang in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-05-05, 13:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×