Derrived Widget not centered on parent when shown as dialog
问题 I have a class MyListWidget derrived from QWidget. I passed parent and flags to the base class QWidget constructor (tried both Qt::Dialog and Qt::Popup in tests) but the custom widget is shown in the center of the screen instead centered to its parent. MyListWidget* myListWidget = new MyListWidget(this, Qt::Dialog); This is the constructor: MyListWidget::MyListWidget(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags), ui(std::auto_ptr<Ui::MyListWidget>(new Ui::MyListWidget)) {