mirror of
https://github.com/jaredtao/TaoQuick.git
synced 2025-01-31 21:22:58 +08:00
view center in screen
This commit is contained in:
parent
74289c893b
commit
6c0fafa650
@ -6,7 +6,7 @@
|
||||
#include <QQmlEngine>
|
||||
#include <QGradient>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QScreen>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
@ -21,6 +21,11 @@ int main(int argc, char **argv)
|
||||
TaoView view;
|
||||
view.rootContext()->setContextProperty("view", &view);
|
||||
view.setSource(QUrl(QStringLiteral("qrc:/Qml/main.qml")));
|
||||
//View center in screen
|
||||
auto screenGeo = app.primaryScreen()->geometry();
|
||||
auto viewGeo = view.geometry();
|
||||
QPoint centerPos = {(screenGeo.width() - viewGeo.width()) / 2, (screenGeo.height() - viewGeo.height()) /2 };
|
||||
view.setPosition(centerPos);
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
|
Loading…
x
Reference in New Issue
Block a user