Results 1 to 4 of 4

Thread: How can i pass a value from qt to qml

  1. #1
    Join Date
    May 2011
    Posts
    120
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33

    Default How can i pass a value from qt to qml

    Qt Code:
    1. {
    2. void Four_in_a_row::resizeEvent(QResizeEvent *f)
    3. {
    4.  
    5. newwidth=f->size().width();
    6. newheigth=f->size().height();
    7. ui->mainframe->setGeometry(0,0,newwidth,newheigth);
    8. qView->setProperty("width", 500);
    9. qDebug()<<qView->width();
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    I wrote a QResize event in Qt. how can i send this newwidth and newheight to qml to set the width and height of rectangle

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

    Default Re: How can i pass a value from qt to qml

    For example you can set a value for some property of an object which is exported to QML. If you bind this property from within QML with some other properties, they will be updated.

    In general look here:
    Using QML with C++
    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.


  3. #3
    Join Date
    May 2011
    Posts
    120
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33

    Default Re: How can i pass a value from qt to qml

    Thanx for the link first. But i am unable to find the correct solution for it
    Can you send me a simple example please


    I really need it to complete my project as i am on the verge of its completion.

    Can you help me please?

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

    Default Re: How can i pass a value from qt to qml

    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.


  5. The following user says thank you to wysota for this useful post:

    vinayaka (14th October 2011)

Similar Threads

  1. Pass value to dialog
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2010, 06:35
  2. how can i pass objects using DBus?
    By mismael85 in forum Qt Programming
    Replies: 14
    Last Post: 17th January 2010, 09:13
  3. Can I pass a default value to a slot?
    By ricardo in forum Qt Programming
    Replies: 4
    Last Post: 8th January 2010, 16:53
  4. Pass by reference in QtScript
    By songyu_us in forum Qt Programming
    Replies: 0
    Last Post: 14th July 2009, 18:59
  5. Pass by reference
    By vermarajeev in forum General Programming
    Replies: 6
    Last Post: 20th July 2007, 15:53

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.