Actually, how to move a button on a widget that is on a QHboxLayout programmatically without Qt Designer.

    2 answers 2

    Using the setGeometry function.

    • Actually, this is the problem, that if you call horizontal_layout->setGeometry(QRect(5,5,5,5)); then nothing happens what am i doing wrong? - Tony Estakado
    • It is necessary ui-> pushButton-> setGeometry (QRect (5,5,5,5)); - Evgeny Shmidt

    The solution was very simple. It is necessary to apply to the layer on which the setContentMargins widget is located (left, top, right, down). Accordingly, this function can be used in the overridden function MouseMoveEvent to move any widget inside layers.