Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Qt Quick custom control (window to display images)

$
0
0
Hi, I’m developing a software using C# and a third party library written in C which includes wrapper DLLs for C++, and .Net. This library can target multiple OSs, and makes use of a “window” from the underlying window manager to to display images and some graphics through a set of display operators. The library provides a .Net WinForm control to allow the placement of one or more of this display windows in the UI, or it is also possible just to open a floating window (from the underlying window manager). An example on how to build a QT custom widget to implement this window control in a QWidget based application is provided. But I wish I could port my software to QT and make use of QTQuick as user interface, because the application is intended for industrial use and it requires an easy and touch enabled UI. So I’m asking if you think it will be possible to easily build a QT Quick control that will allow to place those windows in a Qt Quick UI, and then access the WindowIDs from C++ toin order to use the display operators of the library. Here is the example code for the QTWidget: // QLibWindow.cpp : Implementation of the class QLibWindow //   #include "qLibwindow.h"   #ifdef Q_WS_X11 #if QT_VERSION >= 0x040000   #include <QX11Info> #endif #include <X11/Xlib.h> #endif     QLibWindow::QLibWindow(QWidget *parent, long Width, long Height)         : QWidget(parent) {   resize(Width,Height);   show();   OpenWindow(); }     QLibWindow::~QLibWindow(void) {   using namespace LibCpp;     CloseWindow(WindowID()); }     // Open a Lib window inside the QLibWindow widget void QLibWindow::OpenWindow(void) {   using namespace LibCpp;   #ifdef Q_WS_X11   // In Qt versions older version 3.3, it is necessary to temporarily   // change the SubstructureRedirectMask attribute of a Qt widget   // in order to be able to open a Lib window inside the widget   XWindowAttributes attr; #if QT_VERSION >= 0x040000     XGetWindowAttributes(x11Info().display(),winId(),&attr);   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Info().display(),winId(),                  attr.your_event_mask & ~SubstructureRedirectMask);   XFlush(x11Info().display());   XSync(x11Info().display(),False); #else   XGetWindowAttributes(x11Display(),winId(),&attr);   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Display(),winId(),                  attr.your_event_mask & ~SubstructureRedirectMask);   XFlush(x11Display());   XSync(x11Display(),False); #endif #endif   SetWindowAttr("border_width",0);   SetCheck("~father");   // Open a Lib window with dummy width and height   // it will be resized soon   LibCpp::OpenWindow(0,0,100,100,(Hlong)winId(),"visible","",&WinID);   SetCheck("father"); #ifdef Q_WS_X11   // Reset widget attributes to previous settings (see above comment) #if QT_VERSION >= 0x040000     if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Info().display(),winId(),attr.your_event_mask); #else   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Display(),winId(),attr.your_event_mask); #endif #endif }     // Resize the Lib window whenever the QLibWindow widget is resized void QLibWindow::resizeEvent(QResizeEvent*) {   using namespace LibCpp;   #ifdef Q_WS_X11   // See comment in ::OpenWindow()   XWindowAttributes attr; #if QT_VERSION >= 0x040000     XGetWindowAttributes(x11Info().display(),winId(),&attr);   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Info().display(),winId(),                  attr.your_event_mask & ~SubstructureRedirectMask);   XFlush(x11Info().display());   XSync(x11Info().display(),False); #else   XGetWindowAttributes(x11Display(),winId(),&attr);   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Display(),winId(),                  attr.your_event_mask & ~SubstructureRedirectMask);   XFlush(x11Display());   XSync(x11Display(),False); #endif #endif   // Set the Lib window to its new size.   SetWindowExtents(WindowID(),0,0,width(),height()); #ifdef Q_WS_X11   // See comment in ::OpenWindow() #if QT_VERSION >= 0x040000     if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Info().display(),winId(),attr.your_event_mask); #else   if (attr.your_event_mask & SubstructureRedirectMask)     XSelectInput(x11Display(),winId(),attr.your_event_mask); #endif #endif } If anyone could help me with code, or is interested id developing an example for me, I would be glad. Thanks for any help!

Viewing all articles
Browse latest Browse all 4972

Trending Articles