Question

Question:

Like in css, is there an equivalent of position: fixed; in Qt ?

Picture :

What I want is to move the second bubble (a subclassed QTextEdit) to the left when my main windows is resized. The second picture shows what I want to prevent.

enter image description here enter image description here

Was it helpful?

Solution

Since the bubbles are an instances of QWidget, the simplest thing to do would be to put them into a layout and either left- or right-align them in the layout using bool QLayout::setAlignment(QWidget * w, Qt::Alignment alignment).

You will need to limit the maximum width of the widgets to, say, 2/3 of the overall width of the yellow area, and this will have to be dynamically adjusted. You can do this by installing an event filter to catch QResizeEvent on the area, or implement resizeEvent(QResizeEvent*) on the area's class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top