本文整理汇总了C++中QScreen::logicalDotsPerInch方法的典型用法代码示例。如果您正苦于以下问题:C++ QScreen::logicalDotsPerInch方法的具体用法?C++ QScreen::logicalDotsPerInch怎么用?C++ QScreen::logicalDotsPerInch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScreen
的用法示例。
在下文中一共展示了QScreen::logicalDotsPerInch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPPI
wxSize wxQtDCImpl::GetPPI() const
{
QScreen *srn = QApplication::screens().at(0);
if (!srn)
return wxSize(m_qtPainter->device()->logicalDpiX(), m_qtPainter->device()->logicalDpiY());
qreal dotsPerInch = srn->logicalDotsPerInch();
return wxSize(round(dotsPerInch), round(dotsPerInch));
}
示例2: pixelSize
/**
* 功能描述: 像素点支持尺寸大小计算
* @param index 好友索引
*
* @return 无
*/
int PointSizeToPixelSize::pixelSize(int pointSize)
{
QScreen *screen = gCtx.app_->primaryScreen();
if (!screen) {
return 0;
}
int point_size = (pointSize * screen->logicalDotsPerInch()) / 75;
return point_size;
}
示例3: screenChanged
void UnitsAttached::screenChanged(QScreen *screen)
{
if (screen != m_screen) {
QScreen *oldScreen = m_screen;
m_screen = screen;
if (oldScreen)
oldScreen->disconnect(this);
if (oldScreen == nullptr || screen == nullptr ||
screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch() ||
screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch() ||
screen->devicePixelRatio() != oldScreen->devicePixelRatio()) {
updateDPI();
emit dpChanged();
}
}
}
示例4: main
int main(int argc, char *argv[])
{
QOptions options(get_common_options());
options.add(QLatin1String("QMLPlayer options"))
("scale", 1.0, QLatin1String("scale of graphics context. 0: auto"))
;
options.parse(argc, argv);
if (options.value(QLatin1String("help")).toBool()) {
options.print();
return 0;
}
QGuiApplication app(argc, argv);
QDir::setCurrent(qApp->applicationDirPath());
qDebug() << "arguments======= " << app.arguments();
set_opengl_backend(options.option(QStringLiteral("gl")).value().toString(), app.arguments().first());
load_qm(QStringList() << QStringLiteral("QMLPlayer"), options.value(QStringLiteral("language")).toString());
QtQuick2ApplicationViewer viewer;
QString binDir = qApp->applicationDirPath();
if (binDir.endsWith(QLatin1String(".app/Contents/MacOS"))) {
binDir.remove(QLatin1String(".app/Contents/MacOS"));
binDir = binDir.left(binDir.lastIndexOf(QLatin1String("/")));
}
QQmlEngine *engine = viewer.engine();
if (!engine->importPathList().contains(binDir))
engine->addImportPath(binDir);
qDebug() << engine->importPathList();
engine->rootContext()->setContextProperty(QStringLiteral("PlayerConfig"), &Config::instance());
qDebug(">>>>>>>>devicePixelRatio: %f", qApp->devicePixelRatio());
QScreen *sc = app.primaryScreen();
qDebug() << "dpi phy: " << sc->physicalDotsPerInch() << ", logical: " << sc->logicalDotsPerInch() << ", dpr: " << sc->devicePixelRatio()
<< "; vis rect:" << sc->virtualGeometry();
// define a global var for js and qml
engine->rootContext()->setContextProperty(QStringLiteral("screenPixelDensity"), qApp->primaryScreen()->physicalDotsPerInch()*qApp->primaryScreen()->devicePixelRatio());
qreal r = sc->physicalDotsPerInch()/sc->logicalDotsPerInch();
if (std::isinf(r) || std::isnan(r))
#if defined(Q_OS_ANDROID)
r = 2.0;
#else
r = 1.0;
#endif
float sr = options.value(QStringLiteral("scale")).toFloat();
#if defined(Q_OS_ANDROID)
sr = r;
if (sr > 2.0)
sr = 2.0; //FIXME
#endif
if (qFuzzyIsNull(sr))
sr = r;
engine->rootContext()->setContextProperty(QStringLiteral("scaleRatio"), sr);
QString qml = QStringLiteral("qml/QMLPlayer/main.qml");
if (QFile(qApp->applicationDirPath() + QLatin1String("/") + qml).exists())
qml.prepend(qApp->applicationDirPath() + QLatin1String("/"));
else
qml.prepend(QLatin1String("qrc:///"));
viewer.setMainQmlFile(qml);
viewer.show();
QOption op = options.option(QStringLiteral("width"));
if (op.isSet())
viewer.setWidth(op.value().toInt());
op = options.option(QStringLiteral("height"));
if (op.isSet())
viewer.setHeight(op.value().toInt());
op = options.option(QStringLiteral("x"));
if (op.isSet())
viewer.setX(op.value().toInt());
op = options.option(QStringLiteral("y"));
if (op.isSet())
viewer.setY(op.value().toInt());
if (options.value(QStringLiteral("fullscreen")).toBool())
viewer.showFullScreen();
viewer.setTitle(QStringLiteral("QMLPlayer based on QtAV. [email protected]"));
/*
* find root item, then root.init(argv). so we can deal with argv in qml
*/
#if 1
QString json = app.arguments().join(QStringLiteral("\",\""));
json.prepend(QLatin1String("[\"")).append(QLatin1String("\"]"));
json.replace(QLatin1String("\\"), QLatin1String("/")); //FIXME
QMetaObject::invokeMethod(viewer.rootObject(), "init", Q_ARG(QVariant, json));
//#else
QObject *player = viewer.rootObject()->findChild<QObject*>(QStringLiteral("player"));
if (player) {
AppEventFilter *ae = new AppEventFilter(player, player);
qApp->installEventFilter(ae);
}
QString file;
#ifdef Q_OS_ANDROID
file = QAndroidJniObject::callStaticObjectMethod("org.qtav.qmlplayer.QMLPlayerActivity"
, "getUrl"
, "()Ljava/lang/String;")
.toString();
#endif
if (app.arguments().size() > 1) {
file = options.value(QStringLiteral("file")).toString();
if (file.isEmpty()) {
if (argc > 1 && !app.arguments().last().startsWith(QLatin1Char('-')) && !app.arguments().at(argc-2).startsWith(QLatin1Char('-')))
file = app.arguments().last();
}
//.........这里部分代码省略.........
示例5: run_ui
void run_ui()
{
#ifdef SUBSURFACE_MOBILE
QQmlApplicationEngine engine;
register_qml_types(&engine);
LOG_STP("run_ui qml engine started");
KirigamiPlugin::getInstance().registerTypes();
#if defined(__APPLE__) && !defined(Q_OS_IOS)
// when running the QML UI on a Mac the deployment of the QML Components seems
// to fail and the search path for the components is rather odd - simply the
// same directory the executable was started from <bundle>/Contents/MacOS/
// To work around this we need to manually copy the components at install time
// to Contents/Frameworks/qml and make sure that we add the correct import path
const QStringList importPathList = engine.importPathList();
for (QString importPath: importPathList) {
if (importPath.contains("MacOS"))
engine.addImportPath(importPath.replace("MacOS", "Frameworks"));
}
qDebug() << "QML import path" << engine.importPathList();
#endif // __APPLE__ not Q_OS_IOS
engine.addImportPath("qrc://imports");
DiveListModel diveListModel;
LOG_STP("run_ui diveListModel started");
DiveListSortModel *sortModel = new DiveListSortModel(0);
sortModel->setSourceModel(&diveListModel);
sortModel->setDynamicSortFilter(true);
sortModel->setSortRole(DiveListModel::DiveDateRole);
sortModel->sort(0, Qt::DescendingOrder);
LOG_STP("run_ui diveListModel sorted");
GpsListModel gpsListModel;
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(0);
gpsSortModel->setSourceModel(&gpsListModel);
gpsSortModel->setDynamicSortFilter(true);
gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
gpsSortModel->sort(0, Qt::DescendingOrder);
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("diveModel", sortModel);
ctxt->setContextProperty("gpsModel", gpsSortModel);
ctxt->setContextProperty("vendorList", vendorList);
set_non_bt_addresses();
LOG_STP("run_ui set_non_bt_adresses");
ctxt->setContextProperty("connectionListModel", &connectionListModel);
ctxt->setContextProperty("logModel", MessageHandlerModel::self());
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
LOG_STP("run_ui qml loaded");
qqWindowObject = engine.rootObjects().value(0);
if (!qqWindowObject) {
fprintf(stderr, "can't create window object\n");
exit(1);
}
QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
qml_window->setIcon(QIcon(":subsurface-mobile-icon"));
qDebug() << "qqwindow devicePixelRatio" << qml_window->devicePixelRatio() << qml_window->screen()->devicePixelRatio();
QScreen *screen = qml_window->screen();
QObject::connect(qml_window, &QQuickWindow::screenChanged, QMLManager::instance(), &QMLManager::screenChanged);
QMLManager *manager = QMLManager::instance();
LOG_STP("run_ui qmlmanager instance started");
// now that the log file is initialized...
show_computer_list();
LOG_STP("run_ui show_computer_list");
manager->setDevicePixelRatio(qml_window->devicePixelRatio(), qml_window->screen());
manager->dlSortModel = sortModel;
manager->qmlWindow = qqWindowObject;
manager->screenChanged(screen);
qDebug() << "qqwindow screen has ldpi/pdpi" << screen->logicalDotsPerInch() << screen->physicalDotsPerInch();
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
qml_window->setHeight(1200);
qml_window->setWidth(800);
#endif // not Q_OS_ANDROID and not Q_OS_IOS
qml_window->show();
LOG_STP("run_ui running exec");
#else
MainWindow::instance()->show();
#endif // SUBSURFACE_MOBILE
qApp->exec();
}
示例6: main
int main(int argc, char *argv[])
{
QOptions options(get_common_options());
options.add("QMLPlayer options")
("scale", 1.0, "scale of graphics context. 0: auto")
;
options.parse(argc, argv);
if (options.value("help").toBool()) {
options.print();
return 0;
}
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
qDebug(">>>>>>>>devicePixelRatio: %f", qApp->devicePixelRatio());
QScreen *sc = app.primaryScreen();
qDebug() << "dpi phy: " << sc->physicalDotsPerInch() << ", logical: " << sc->logicalDotsPerInch() << ", dpr: " << sc->devicePixelRatio()
<< "; vis rect:" << sc->virtualGeometry();
// define a global var for js and qml
viewer.engine()->rootContext()->setContextProperty("screenPixelDensity", qApp->primaryScreen()->physicalDotsPerInch()*qApp->primaryScreen()->devicePixelRatio());
qreal r = sc->physicalDotsPerInch()/sc->logicalDotsPerInch();
if (std::isinf(r) || std::isnan(r))
#if defined(Q_OS_ANDROID)
r = 2.0;
#else
r = 1.0;
#endif
float sr = options.value("scale").toFloat();
if (qFuzzyIsNull(sr))
sr = r;
viewer.engine()->rootContext()->setContextProperty("scaleRatio", sr);
QString qml = "qml/QMLPlayer/main.qml";
if (QFile(qApp->applicationDirPath() + "/" + qml).exists())
qml.prepend(qApp->applicationDirPath() + "/");
else
qml.prepend("qrc:///");
viewer.setMainQmlFile(qml);
viewer.showExpanded();
QOption op = options.option("width");
if (op.isSet())
viewer.setWidth(op.value().toInt());
op = options.option("height");
if (op.isSet())
viewer.setHeight(op.value().toInt());
op = options.option("x");
if (op.isSet())
viewer.setX(op.value().toInt());
op = options.option("y");
if (op.isSet())
viewer.setY(op.value().toInt());
if (options.value("fullscreen").toBool())
viewer.showFullScreen();
viewer.setTitle("QMLPlayer based on QtAV. [email protected]");
/*
* find root item, then root.init(argv). so we can deal with argv in qml
*/
#if 1
QString json = app.arguments().join("\",\"");
json.prepend("[\"").append("\"]");
json.replace("\\", "/"); //FIXME
QMetaObject::invokeMethod(viewer.rootObject(), "init", Q_ARG(QVariant, json));
//#else
if (app.arguments().size() > 1) {
qDebug("arguments > 1");
QObject *player = viewer.rootObject()->findChild<QObject*>("player");
QString file = options.value("file").toString();
if (player && !file.isEmpty()) {
if (QFile(file).exists())
file.prepend("file://");
file.replace("\\", "/"); //qurl
QMetaObject::invokeMethod(player, "play", Q_ARG(QUrl, QUrl(file)));
}
}
#endif
QObject::connect(viewer.rootObject(), SIGNAL(requestFullScreen()), &viewer, SLOT(showFullScreen()));
QObject::connect(viewer.rootObject(), SIGNAL(requestNormalSize()), &viewer, SLOT(showNormal()));
ScreenSaver::instance().disable(); //restore in dtor
return app.exec();
}