Skip to content

Commit

Permalink
view center in screen
Browse files Browse the repository at this point in the history
jared2020 committed Jul 18, 2019
1 parent 74289c8 commit 6c0fafa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion TaoQuickDemo/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 6c0fafa

Please sign in to comment.