本文整理汇总了C++中QQmlEngine::addImageProvider方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlEngine::addImageProvider方法的具体用法?C++ QQmlEngine::addImageProvider怎么用?C++ QQmlEngine::addImageProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlEngine
的用法示例。
在下文中一共展示了QQmlEngine::addImageProvider方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
qmlRegisterType<Hider>("com.ics.demo", 1, 0, "Hider");
int rc = 0;
QQmlEngine engine;
QQmlComponent *component = new QQmlComponent(&engine);
QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
component->loadUrl(QUrl("../../Source/main.qml"));
Hider::image_provider = new ImageProvider;
engine.addImageProvider("images", Hider::image_provider);
if (!component->isReady() ) {
qWarning("%s", qPrintable(component->errorString()));
return -1;
}
QObject *topLevel = component->create();
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
QSurfaceFormat surfaceFormat = window->requestedFormat();
window->setFormat(surfaceFormat);
window->show();
rc = app.exec();
delete component;
return rc;
}
示例2: init
//==============================================================================
// Init
//==============================================================================
void ViewerWindow::init()
{
qDebug() << "ViewerWindow::init";
// Set Read Only Mode
ui->textEdit->setReadOnly(!editMode);
// Connect Signal
connect(ui->textEdit, SIGNAL(textChanged()), this, SLOT(textChanged()));
// Quick Widget Set Visible
ui->quickWidget->setVisible(true);
// Text Edit Set Visible
ui->textEdit->setVisible(false);
// Set Context Properties
QQmlContext* ctx = ui->quickWidget->rootContext();
// Set Context Properties - Viewer Content
ctx->setContextProperty(DEFAULT_IMAGE_VIEWER_CONTENT, fileName);
// Get Engine
QQmlEngine* engine = ui->quickWidget->engine();
// Add Image Provider
engine->addImageProvider(QLatin1String(DEFAULT_AUDIO_TAG_PROVIDER_ID), new AudioTagImageProvider());
// Set Resize Mode
ui->quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
// Set Focus Policy
setFocusPolicy(Qt::StrongFocus);
// ...
}
示例3: engineAddImageProvider
void engineAddImageProvider(QQmlEngine_ *engine, QString_ *providerId, void *imageFunc)
{
QQmlEngine *qengine = reinterpret_cast<QQmlEngine *>(engine);
QString *qproviderId = reinterpret_cast<QString *>(providerId);
qengine->addImageProvider(*qproviderId, new GoImageProvider(imageFunc));
}
示例4: main
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
// Use QCommandLineParser to parse arguments (see documentation)
QQmlEngine engine;
// Register needed types
registerQmlTypes();
// Add image provider
engine.addImageProvider(QStringLiteral("svgelement"), new qtouch::SvgElementProvider(QQmlImageProviderBase::Image,
QUrl(QStringLiteral("qrc:///images/"))));
qtouch::DataModel dataModel;
try
{
dataModel.init();
}
catch (qtouch::Exception& e)
{
qCritical() << e.message();
return EXIT_FAILURE;
}
qtouch::CourseModel* courseModel = new qtouch::CourseModel(&dataModel, &app);
qtouch::ProfileModel* profileModel = new qtouch::ProfileModel(&dataModel, &app);
// Embed view models
engine.rootContext()->setContextProperty("$courseModel", courseModel);
engine.rootContext()->setContextProperty("$profileModel", profileModel);
// Create root component
QQmlComponent component(&engine);
QQuickWindow::setDefaultAlphaBuffer(true);
component.loadUrl(QUrl(QStringLiteral("qrc:/qml/MainWindow.qml")));
if (componentError(&component))
return EXIT_FAILURE;
if (component.isReady())
{
component.create();
if (componentError(&component))
return EXIT_FAILURE;
}
else
{
qWarning() << component.errorString();
return EXIT_FAILURE;
}
// FIXME: Not nice but fixes initialization problem
courseModel->selectCourse(0);
return app.exec();
}
示例5: options
Launcher::Launcher( int& argc, char* argv[] )
: QGuiApplication( argc, argv )
{
const CommandLineOptions options( argc, argv );
const MasterConfiguration config( options.getConfiguration( ));
const auto deflectStreamId = options.getStreamId().toStdString();
_qmlStreamer.reset( new deflect::qt::QmlStreamer( deflectQmlFile,
deflectHost,
deflectStreamId ));
connect( _qmlStreamer.get(), &deflect::qt::QmlStreamer::streamClosed,
this, &QCoreApplication::quit );
auto item = _qmlStreamer->getRootItem();
// General setup
item->setProperty( "restPort", config.getWebServicePort( ));
if( options.getWidth( ))
item->setProperty( "width", options.getWidth( ));
if( options.getHeight( ))
item->setProperty( "height", options.getHeight( ));
// FileBrowser setup
const auto filters = ContentFactory::getSupportedFilesFilter();
item->setProperty( "filesFilter", filters );
item->setProperty( "rootFilesFolder", config.getContentDir( ));
item->setProperty( "rootSessionsFolder", config.getSessionsDir( ));
QQmlEngine* engine = _qmlStreamer->getQmlEngine();
#if TIDE_ASYNC_THUMBNAIL_PROVIDER
engine->addImageProvider( thumbnailProviderId, new AsyncThumbnailProvider );
#else
engine->addImageProvider( thumbnailProviderId, new ThumbnailProvider );
#endif
engine->rootContext()->setContextProperty( "fileInfo", &_fileInfoHelper );
// DemoLauncher setup
item->setProperty( "demoServiceUrl", config.getDemoServiceUrl( ));
item->setProperty( "demoServiceImageFolder",
config.getDemoServiceImageFolder( ));
item->setProperty( "demoServiceDeflectHost", QHostInfo::localHostName( ));
}
示例6: main
int main(int argc, char *argv[])
{
qmlRegisterType<SettingsUi>("harbour.tohkbd2.settingsui", 1, 0, "SettingsUi");
qmlRegisterType<ConsoleModel>("harbour.tohkbd2.ConsoleModel", 1, 0, "ConsoleModel");
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
QTranslator engineeringTranslator;
engineeringTranslator.load("engineering_en", SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&engineeringTranslator);
QTranslator translator;
translator.load(QLocale::system().name(), SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&translator);
QScopedPointer<QQuickView> view(SailfishApp::createView());
QQmlEngine *engine = view->engine();
engine->addImageProvider(QLatin1String("tohkbd2"), new IconProvider);
QString viewMode;
if (argc > 1)
viewMode = QString(argv[1]);
if (!viewMode.startsWith("--"))
viewMode = QString();
view->rootContext()->setContextProperty("viewMode", viewMode);
view->setSource(SailfishApp::pathTo("qml/tohkbd2-settingsui.qml"));
view->show();
QObject::connect(engine, SIGNAL(quit()), app.data(), SLOT(quit()));
return app->exec();
}
示例7: dockQmlToWidget
QWidget* GUIExchangesWidget::dockQmlToWidget()
{
QQuickView* pExchangesWindow = new QQuickView;
QWidget* pPlaceHolder = 0;
if ( pExchangesWindow )
{
QQmlContext* pContext = pExchangesWindow->rootContext();
if ( pContext )
{
pContext->setContextProperty( "GUI20Skin", &GUI20Skin::Instance() );
}
QQmlEngine* pEngine = pExchangesWindow->engine();
if ( pEngine )
{
m_pQmlImageProvider = new QmlImageProvider();
pEngine->addImageProvider( "exchangesImages", m_pQmlImageProvider );
}
pExchangesWindow->setSource( QUrl( QStringLiteral( "qrc:/qml/qtquick_controls/qml/QmlGUIExchangesWindow.qml" ) ) );
QQuickItem* pRootObject = pExchangesWindow->rootObject();
if ( pRootObject )
{
m_pExchangesControl = pRootObject->findChild<GUIExchangesControl*>();
if ( m_pExchangesControl )
{
}
}
pPlaceHolder = QWidget::createWindowContainer( pExchangesWindow, this );
if ( pPlaceHolder )
{
pPlaceHolder->setMinimumSize( 500, 170 );
pPlaceHolder->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
}
}
return pPlaceHolder;
}
示例8: main
int main(int argc, char *argv[])
{
setenv("USE_ASYNC", "1", 1);
QQuickWindow::setDefaultAlphaBuffer(true);
QScopedPointer<QGuiApplication> application(SailfishApp::application(argc, argv));
application->setApplicationName("harbour-webpirate");
pluginenv();
ProxyManager::loadAndSet();
QDBusConnection sessionbus = QDBusConnection::sessionBus();
if(sessionbus.interface()->isServiceRegistered(WebPirateInterface::INTERFACE_NAME)) // Only a Single Instance is allowed
{
WebPirateInterface::sendArgs(application->arguments().mid(1)); // Forward URLs to the running instance
if(application->hasPendingEvents())
application->processEvents();
return 0;
}
FilesModel::registerMetaTypes();
qmlRegisterType<AbstractDownloadItem>("harbour.webpirate.Private", 1, 0, "DownloadItem");
qmlRegisterType<FavoriteItem>("harbour.webpirate.Private", 1, 0, "FavoriteItem");
qmlRegisterType<MimeDatabase>("harbour.webpirate.Private", 1, 0, "MimeDatabase");
qmlRegisterType<TranslationInfoItem>("harbour.webpirate.Translation", 1, 0, "TranslationInfoItem");
qmlRegisterType<TranslationsModel>("harbour.webpirate.Translation", 1, 0, "TranslationsModel");
qmlRegisterSingletonType<AES256>("harbour.webpirate.Security", 1, 0, "AES256", &AES256::initialize);
qmlRegisterSingletonType<NetworkInterfaces>("harbour.webpirate.Network", 1, 0, "NetworkInterfaces", &NetworkInterfaces::initialize);
qmlRegisterSingletonType<MachineID>("harbour.webpirate.DBus", 1, 0, "MachineID", &MachineID::initialize);
qmlRegisterSingletonType<Ofono>("harbour.webpirate.DBus", 1, 0, "Ofono", &Ofono::initialize);
qmlRegisterType<DefaultBrowser>("harbour.webpirate.DBus", 1, 0, "DefaultBrowser");
qmlRegisterType<WebPirateInterface>("harbour.webpirate.DBus", 1, 0, "WebPirateInterface");
qmlRegisterType<ScreenBlank>("harbour.webpirate.DBus", 1, 0, "ScreenBlank");
qmlRegisterType<UrlComposer>("harbour.webpirate.DBus", 1, 0, "UrlComposer");
qmlRegisterType<NotificationManager>("harbour.webpirate.DBus.Notifications", 1, 0, "Notifications");
qmlRegisterType<TransferEngine>("harbour.webpirate.DBus.TransferEngine", 1, 0, "TransferEngine");
qmlRegisterType<TransferMethodModel>("harbour.webpirate.DBus.TransferEngine", 1, 0, "TransferMethodModel");
qmlRegisterType<ProxyManager>("harbour.webpirate.Network", 1, 0, "ProxyManager");
qmlRegisterType<AdBlockEditor>("harbour.webpirate.AdBlock", 1, 0, "AdBlockEditor");
qmlRegisterType<AdBlockDownloader>("harbour.webpirate.AdBlock", 1, 0, "AdBlockDownloader");
qmlRegisterType<AdBlockManager>("harbour.webpirate.AdBlock", 1, 0, "AdBlockManager");
qmlRegisterType<CookieJar>("harbour.webpirate.WebKit", 1, 0, "CookieJar");
qmlRegisterType<WebKitDatabase>("harbour.webpirate.WebKit", 1, 0, "WebKitDatabase");
qmlRegisterType<WebIconDatabase>("harbour.webpirate.WebKit", 1, 0, "WebIconDatabase");
qmlRegisterType<DownloadManager>("harbour.webpirate.WebKit", 1, 0, "DownloadManager");
qmlRegisterType<ClipboardHelper>("harbour.webpirate.Helpers", 1, 0, "ClipboardHelper");
qmlRegisterType<FilesModel>("harbour.webpirate.Selectors", 1, 0, "FilesModel");
qmlRegisterType<FavoritesManager>("harbour.webpirate.LocalStorage", 1, 0, "FavoritesManager");
QScopedPointer<QQuickView> view(SailfishApp::createView());
QQmlEngine* engine = view->engine();
QObject::connect(engine, SIGNAL(quit()), application.data(), SLOT(quit()));
engine->addImageProvider(WebIconDatabase::PROVIDER_NAME, new FaviconProvider());
view->setSource(SailfishApp::pathTo("qml/harbour-webpirate.qml"));
view->show();
return application->exec();
}