Search code examples
c++qtqt5qspinbox

How to set QSpinBox in a particular position of mainwindow.ui interface?


I know how to include QSpinBox in user interface by coding.

QSpinBox *spinbox= new QSpinBox(this);

Now I am looking for such a function by which I can set the QSpinBox in a particular position in user interface by giving coordinates value of this position.

I tried a couple of functions, but now one is giving me right solution how I would like to have?

Are there any such function in Qt? Thanks in advance.


Solution

  • To place a widget in a certain position you must use the move() function, keep in mind that the widget should not be contained in any layout

    spinbox->move(x, y);
    

    or:

    Qpoint p(x, y);
    spinbox->move(p);