我正在使用Qt,但我不知道如何将QMainWindow窗口居中。我写了这段代码,但它不能工作。提前谢谢。 QRect screenGeometry = QApplication::desktop()->screenGeometry();
int x = (screenGeometry.width() - w->width()) / 2;
int y = (screenGeometry.height() - w->height()) / 2;
w->move(x, y); // w is a QMainWindow pointer 我明白了: ?