本文整理汇总了C++中QObject::isWindowType方法的典型用法代码示例。如果您正苦于以下问题:C++ QObject::isWindowType方法的具体用法?C++ QObject::isWindowType怎么用?C++ QObject::isWindowType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObject
的用法示例。
在下文中一共展示了QObject::isWindowType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget widget;
widget.setWindowTitle(QT_VERSION_STR);
QHBoxLayout *hLayout = new QHBoxLayout(&widget);
QGroupBox *groupBox = new QGroupBox("QuickWidget", &widget);
QVBoxLayout *vLayout = new QVBoxLayout(groupBox);
QQuickWidget *quickWidget = new QQuickWidget(groupBox);
quickWidget->setMinimumSize(360, 520);
vLayout->addWidget(quickWidget);
quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
quickWidget->setSource(QUrl(QLatin1String("qrc:/main.qml")));
if (quickWidget->status() == QQuickWidget::Error) {
qWarning() << quickWidget->errors();
return 1;
}
hLayout->addWidget(groupBox);
const QUrl gallerySource(QLatin1String("qrc:/gallery.qml"));
QQmlApplicationEngine engine(gallerySource);
QObject *root = engine.rootObjects().value(0, Q_NULLPTR);
if (!root || !root->isWindowType()) {
qWarning() << "Load error" << gallerySource;
return 1;
}
groupBox = new QGroupBox("QQuickView/createWindowContainer", &widget);
vLayout = new QVBoxLayout(groupBox);
QWidget *container = QWidget::createWindowContainer(qobject_cast<QWindow *>(root), groupBox);
container->setMinimumSize(360, 520);
vLayout->addWidget(container);
hLayout->addWidget(groupBox);
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&widget);
widget.move(availableGeometry.center() - QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height() / 2));
widget.show();
return app.exec();
}
示例2: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
const QString app_name("timecop");
const QString app_version("1.1");
const QString app_settings_dir(QDir::home().filePath(".timecop"));
app.setOrganizationName("Daimler AG RD-DDA");
app.setApplicationName(app_name);
QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings::setPath(QSettings::IniFormat,
QSettings::UserScope,
app_settings_dir);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *root = 0;
QWidget *rootWindow = 0;
SystrayHelper systrayHelper;
engine.rootContext()->setContextProperty("systrayHelper", &systrayHelper);
engine.rootContext()->setContextProperty("app_name", app_name);
engine.rootContext()->setContextProperty("app_version", app_version);
engine.rootContext()->setContextProperty("app_settings_dir", app_settings_dir);
if (engine.rootObjects().size() > 0)
{
root = engine.rootObjects().at(0);
systrayHelper.setRootWindow(root);
if(root->isWindowType()){
rootWindow = qobject_cast<QWidget*>(root);
QApplication::setQuitOnLastWindowClosed(false);
QAction *minimizeAction = new QAction(QObject::tr("Mi&nimize"), rootWindow);
rootWindow->connect(minimizeAction, SIGNAL(triggered()), root, SLOT(hide()));
QAction *maximizeAction = new QAction(QObject::tr("Ma&ximize"), rootWindow);
rootWindow->connect(maximizeAction, SIGNAL(triggered()), root, SLOT(showMaximized()));
QAction *restoreAction = new QAction(QObject::tr("&Restore"), rootWindow);
rootWindow->connect(restoreAction, SIGNAL(triggered()), root, SLOT(showNormal()));
QAction *quitAction = new QAction(QObject::tr("&Quit"), rootWindow);
rootWindow->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenu *trayIconMenu = new QMenu(rootWindow);
trayIconMenu->addAction(minimizeAction);
trayIconMenu->addAction(maximizeAction);
trayIconMenu->addAction(restoreAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
QSystemTrayIcon *trayIcon = new QSystemTrayIcon(rootWindow);
QIcon icon(":/trayicon.png");
icon.setIsMask(true);
//trayIcon->setContextMenu(trayIconMenu);
trayIcon->setIcon(icon);
trayIcon->setToolTip("Click to open");
trayIcon->setVisible(true);
systrayHelper.setTrayIcon(trayIcon);
QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &systrayHelper, SLOT(activatedSystray(QSystemTrayIcon::ActivationReason)));
trayIcon->show();
}
}
return app.exec();
}