Results 1 to 2 of 2

Thread: Connecting QML signals with Qt slots

  1. #1
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Connecting QML signals with Qt slots

    Here is an example of qml:

    Qt Code:
    1. Item {
    2. signal titleBarClicked()
    3.  
    4. MouseArea {
    5. anchor.fill: parent
    6. onClicked: titleBarClicked()
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    and C++:

    Qt Code:
    1. QDeclarativeEngine *engine = new QDeclarativeEngine;
    2. QDeclarativeComponent component(engine, QUrl::fromLocalFile("qml/TestQML/TestQML.qml"));
    3. QObject *myObject = component.create();
    4. QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(myObject);
    5. qDebug()<<QObject::connect(item, SIGNAL(titleBarClicked()), &viewer, SLOT(showMaximized()));
    To copy to clipboard, switch view to plain text mode 

    connect() return true, but slot is not called. What's wrong?

    P.S. If you want to vote for this bug - go there

  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: Connecting QML signals with Qt slots

    Did you read the comment to the bug?
    ==========================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.

Similar Threads

  1. Replies: 8
    Last Post: 18th July 2009, 16:57
  2. Connecting signals and slots help pls
    By bod in forum Qt Programming
    Replies: 9
    Last Post: 1st July 2008, 16:01
  3. problem with connecting signals with slots"
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2007, 17:44
  4. Connecting signals & slots across different threads
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 13:40
  5. Connecting slots/signals in subclassed form
    By qball2k5 in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2006, 17:01

Tags for this Thread

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.