Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
What should we use as a container
Leon_2001 last edited by
there is often the the situation where you need kind of a container, where you just put multiple elements in to position them.
But I was wondering what is the best element to do so. Btw. I use qt Quick controls .
So there are the following elements:
So the first one draws a background unless I say color: "transparent", so probably not the best way to go. The thrid and fourth things have paddings and also a background, which might be good under some circumstances, but not always. Container seems prett logical, but it doesn't seem to work. And item works perfectly, but isn't very semantic. Item could be anything .
So actually Container would be probably the best, but it doesn't work. At the moment I'm using Item. What do you use or consider as the best?
Flesh last edited by Flesh
@Leon_2001 You would have to give an example of what you are trying to do, from what you mention it seems like Column or Row, which are positioner's, would be a better option inside a container, but your question is about containers themselves, but by themselves they just containers, and their use is more of a base, and you use each one differently depending on what you need to do, but it sounds like you might be better off looking at Layout and Views as tools for use with containers to add controls too.
I look at it his way:
Container: This is a base class, that you derive or extend from, it is a special use Container, when you do not want other methods implemented, and want to implement them yourself.
Rectangle: Use this if you want content inside of a Rectangle, this is mostly for visual items.
Item: Use this if you have an Item that requires more visual control than Rectangle.
Pane: Use this inside a layout positioner, by it self it only defines a region.
Page: Is a high level container control, that makes it easy to add content and add a header or footer.
One container does not rule them all, by themselves they are just building blocks.
I hope that helps.