Dear friends,

I created UI for widget using QtDesigner, and now I want to customize it a little bit before showing to the user. So I'm trying to do this in the widget's constructor:
Qt Code:
  1. public:
  2. MyWidget(QWidget *_parent) : QWidget(_parent)
  3. {
  4. ui.setupUi(this);
  5.  
  6. ....
  7. // For example: let's move the checkbox
  8. QPoint p1 = ui.checkBox1->mapToGlobal(QPoint(0, 0));
  9. QPoint p2 = ui.checkBox2->mapToGlobal(QPoint(0, 0));
  10. ui.checkBox->setStyleSheet(QString("margin-left:%1px;").arg(p1.x()-p2.x())); // oops
  11. ...
  12. }
To copy to clipboard, switch view to plain text mode 

But here I face the problem: p1 and p2 are just the same.

So, I'm wondering:

1. Why they are the same?

2. Is it possible to perform such customization in widget's constructor? I know that "QTimer::singleShot(0, this, SLOT(moveMyCheckbox() ))" will solve this, but I'm not sure if it is not a "dirty hack".

3. What is the best way to do such things?