Results 1 to 8 of 8

Thread: QtQuick 2 child list

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QtQuick 2 child list

    Hello,
    I have on QML few visual items, but some of them are added from within C++ code.
    Now I need to access them from within QML on i.e. resize event.

    I tried children.lenght but this is undefined.

    Is there a way to iterate in QML over items children?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    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: QtQuick 2 child list

    If you wish to run imperative code from within QML as a result of some event then I think your approach is not that much correct.
    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
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QtQuick 2 child list

    Thanks for the reply.
    It was actually typo:

    children.lenght vs children.length
    Code that is run there only change item width, exactly width of combobox popup after rescale.

    PS. Reason why I iterate over children's is that I add items from within C++, and it's object names comes from different place - external file, so it's easier for me to just iterate then actually change it from C++ because I don't keep track of them, only find parent during add operation.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  4. #4
    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: QtQuick 2 child list

    Quote Originally Posted by Talei View Post
    Code that is run there only change item width, exactly width of combobox popup after rescale.
    Why not use a binding?

    PS. Reason why I iterate over children's is that I add items from within C++
    You can still bind properties to expressions.
    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. #5
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QtQuick 2 child list

    Because It's large application and I want to remove from c++ as much as I can.
    QML pages content is changeable dynamically and I don't want to use binding just to change items width on resize event.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  6. #6
    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: QtQuick 2 child list

    Quote Originally Posted by Talei View Post
    QML pages content is changeable dynamically and I don't want to use binding just to change items width on resize event.
    That's one of the reasons why you'd want to set a binding.
    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.


  7. #7
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QtQuick 2 child list

    Is it worth doing that just to change the width for 1 object?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  8. #8
    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: QtQuick 2 child list

    I have no idea whether it is "worth" or not. I only know that if you use a declarative environment, you should program in a declarative way. At some point you might want to change something in your code and your imperative code might interfere with your changes causing you headache, nausea and other side effects. There is a Binding element in QML that does exactly what you want. However having read the thread again I think your initial problem might be that you interfere with GUI QML code from C++. Usually you'd do it the other way -- expose objects in C++ and then use them in QML. "Pulling" QML objects into C++ is considered bad practice.
    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.


Similar Threads

  1. QtQuick 2.1
    By shadowroot in forum Qt Quick
    Replies: 1
    Last Post: 6th April 2013, 08:44
  2. add child item in list view
    By johan07 in forum Newbie
    Replies: 3
    Last Post: 3rd January 2013, 09:54
  3. What is QtQuick/QML really for?
    By Huk in forum Qt Quick
    Replies: 7
    Last Post: 21st June 2012, 20:33
  4. Designer or QtQuick?
    By Jeffb in forum Qt Quick
    Replies: 5
    Last Post: 9th August 2011, 06:38
  5. List of child widgets includes layout
    By JovianGhost in forum Qt Programming
    Replies: 5
    Last Post: 11th May 2010, 03:22

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.