Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Image Manager/Cvb++/QmlImageDisplay

This example program is located in your CVB installation under %CVB%Tutorial/Image Manager/Cvb++/QmlImageDisplay.

main.cpp:

// The QmlImageDisplay example shows an image in a Qt display. With mouse over the pixel data are
// shown.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
#include <iostream>
#include <QApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QIcon>
#include <cvb/ui/image_view_item.hpp>
#include <cvb/image.hpp>
int main(int argc, char* argv[])
{
try
{
QApplication app(argc, argv);
// register QML components for an image display
Cvb::UI::ImageViewItem::Register();
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setIcon(QIcon(":/qttutorial.png"));
auto context = view.rootContext();
// create a controller object to communicate with QML
Cvb::UI::ImageController imageController;
context->setContextProperty("mainImage", &imageController);
// load main QML file
view.setSource(QUrl::fromLocalFile("../main.qml"));
// load the image
Cvb::ImagePtr image = Cvb::Image::Load(Cvb::InstallPath() + CVB_LIT("tutorial/ClaraRGB.bmp"));
// refresh the image display through the controller object
imageController.Refresh(image);
view.resize(640, 480);
view.show();
return app.exec();
}
catch (const std::exception& error)
{
std::cout << error.what() << std::endl;
}
}
static std::unique_ptr< Image > Load(const String &fileName)
std::shared_ptr< Image > ImagePtr
String InstallPath()