Results 1 to 2 of 2

Thread: Get element in Qgridlayout

  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2

    Default Get element in Qgridlayout

    I have a question about accessing items in a Qlayout like Qgridlayout, vertical layouts and horizontal layouts...
    Well the item I put inside the layout is:
    class CardGui : public QToolButton

    I'm planning to make a card list... And having access to the elements could be important then.

    There is a function itematposition which returns a QLayoutItem.

    How can I change this to my CardGui button... with a dynamic cast or could it be something more complex?
    Or Am I doing this wrong?

    Thx in advance,

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Get element in Qgridlayout

    QLayoutItem widget() method looks like it does what you need, but i never used it so you should test it and see if it helps.

    Another way is to keep pointers to CardGui into some data structure (like QVector<CardGui*> or if you like QVector<QVector<...) this won't be such and overhead and you can then access every widget very easy.

Similar Threads

  1. QML video element and UNC paths
    By Fastman in forum Qt Quick
    Replies: 0
    Last Post: 14th June 2011, 11:07
  2. [QML] Video element
    By grezly in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2011, 18:26
  3. Remove element of xml
    By VitaliBR in forum Newbie
    Replies: 17
    Last Post: 16th February 2011, 14:28
  4. Help with QML Pathview element
    By chetu1984 in forum Newbie
    Replies: 0
    Last Post: 7th February 2011, 05:49
  5. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 14: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.