QStackedWidget vs. QStackedLayout



  • Hi,
    I need to have in my app area which changes while user interaction and both of these classes seem to be solution to my problem. I've read documentation of both and it's very similar. So what are main differences? Is any of them obsolete/depreciated (as with *widget and *views)?



  • QStackedWidget is a convenience class built on top of QStackedLayout. The main difference is that QStackedWidget inherits QWidget (through QFrame), while QStackedLayout does not. Summing up, QStackedWidget can be used as a toplevel widget, while QStackedLayout have to be put in a QWidget.



  • The former is a widget, the latter is a layout. The widget itself is a simple convenience QWidget using QStackedLayout and exposing its API. Use the one that best fits your requirements. End of the story :)

    BTW, *widget and *views are not deprecated at all, they just cover different use cases.



  • And the document has this

    bq. QStackedWidget is a convenience layout widget built on top of the QStackedLayout class.

    Edit Did't refresh the page and so missed the above replies.



  • OK, thanks for your answers - layout will do the work for me.

    peppe: according to some "documentation":http://doc.qt.nokia.com/4.7/model-view-programming.html#convenience-classes it seems that widgets stays to be "compatible" with Qt3.

    "These classes are less flexible than the view classes, and cannot be used with arbitrary models. We recommend that you use a model/view approach to handling data in item views unless you strongly need an item-based set of classes."



  • [quote author="maciek" date="1292417292"]OK, thanks for your answers - layout will do the work for me.

    peppe: according to some "documentation":http://doc.qt.nokia.com/4.7/model-view-programming.html#convenience-classes it seems that widgets stays to be "compatible" with Qt3.

    "These classes are less flexible than the view classes, and cannot be used with arbitrary models. We recommend that you use a model/view approach to handling data in item views unless you strongly need an item-based set of classes."[/quote]

    Their API is similar, sure, but this doesn't make them outdated or deprecated. They have their (very limited and specific) use case, that's it :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.