PDA

View Full Version : Get element in Qgridlayout



dieter
11th February 2012, 17:34
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,

Zlatomir
12th February 2012, 09:51
QLayoutItem widget() (http://developer.qt.nokia.com/doc/qt-4.8/qlayoutitem.html#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.