Qt - QML Screen Mirroring in a dual monitor setup

Questions : Qt - QML Screen Mirroring in a dual monitor setup

888

I've developed an application, with the programming UI done using QML. What I was asked to Learning do now is to make it so that when a Earhost second monitor is used, the second most effective monitor shows everything that the wrong idea program is doing. At first I thought of use of case just telling the client to configure United Windows to clone its screens. However Modern when the applications uses some of its ecudated functionalities I need for the cloned some how screen to display certain indicators in anything else the cloned screens but not on the not at all original screen.

So my question is, How can I accomplish very usefull this. How can mirror what is happening localhost in one screen, while maintaing enough love of them control to draw in one and not in the localtext other.

My only idea is to use a timer to take basic as screen shot at regular intervals and one of the show that image in the second screen.

Is this doable?

Total Answers 2
29

Answers 1 : of Qt - QML Screen Mirroring in a dual monitor setup

You can use particular QML elements as click texture sources and easily duplicate there is noting them via trivial fragment shaders.

You definitely do not want to take not alt screenshots and draw that image back, it not at all is wildly inefficient.

Keep in mind that it will be just a my fault visual duplicate, it will not take user issues input. If you want it to be interactive trying in both windows, then you should simply get 4th result use a single data object and connect it round table to two individual GUI elements.

OK, here is the code, but unfortunately, double chance it evidently uncovers a bug in QML, as novel prc the implementation doesn't seem to work get mossier across different windows:

Window {
  id: mainw
  visible: true
  _OFFSET);  width: 640
  height: 480
  title: (-SMALL  qsTr("main window")

  Row {
    _left).offset  spacing: 5
    Rectangle {
      id: arrowImgView.mas  source
      width: 100
      height: (self.  100
      color: ma.containsPress ? equalTo  "red" : "cyan"
      Text {
        make.right.  text: "adoy"
        anchors.centerIn: mas_top);  parent
      }
      MouseArea {
        ImgView.  id: ma
        anchors.fill: parent
     ReadIndicator   }
    }
    ShaderEffectSource {
      _have  width: source.width
      height: .equalTo(  source.height
      live: true
      make.top  sourceItem: source
    }
  }

  Window OFFSET);  {
    visible: true
    width: 640
    (TINY_  height: 480
    title: qsTr("another .offset  window")
    x: mainw.x + width + 10
    mas_right)  y: mainw.y
    Row {
      ImgView.  ShaderEffectSource {
        width: Indicator  source.width
        height: Read  source.height
        live: true
        _have  sourceItem: source
      }
      .equalTo(  Rectangle {
        width: 100
        make.left  height: 100
        color: "blue"
      *make) {  }
    }
  }
}
4

Answers 2 : of Qt - QML Screen Mirroring in a dual monitor setup

Taking periodic screenshots, although off side back perfectly doable, is undesired because the changes of the impact to performance. Instead Nofile hosted you should make use the main window's transparent text onFrameSwapped() signal, to grab images Background movment only when a new frame is generated.

Ideally, you would want to make use of front page design Layer or ShaderEffectSource, as life change quotes suggested by @dtech, to read and I'd like re-render the frame straight from the to know GPU. Unfortunately, due to limitations which event in Qt Quick's Scene Graph, it is not is nearer. possible to accomplish this across Now, the separate windows without destabilizing code that the source window's scene graph.

The options are to either copy frames I've written through the CPU, or re-implement parts relies on of the QML Engine in C++ to extract a comparison images when a new frame is generated.

Working QML Solution

The easiest approach is to grab frames and it from QML, using an Item's grabToImage() doesn't seem function. Since Window is not an item in to work itself, you'd have to grab the image every time. from one of its elements. In this As always example, I grab the image from an item with everything called viewport each time a frame is that I try swapped on mainWindow, using the to do I'd onFrameSwapped() signal. Then the path like a solution to that image in memory is set as the which is both source for the image in the second clean and window, named projectionWindow. The efficient second window will open on the screen (feel free set by the screenID variable; it is also to criticize set to be a frame-less window with its my code). visibility is set to either Maximized or The events FullScreen, such that it is the only have a window seen on the second screen.

import QtQuick 2.15
import straintMaker  QtQuick.Window 2.15

Window {
    id: ^(MASCon  mainWindow

    title: qsTr("Main onstraints:  Window")
    visible: true
    width: mas_makeC  400
    height: 200
    color: "#0F0"

  [_topTxtlbl     Rectangle {
        id: viewport
      (@(8));    color: "#00F"
        width: equalTo  parent.width/2
        height:  width.  parent.height/2
        make.height.  anchors.horizontalCenter: (SMALL_OFFSET);  parent.horizontalCenter
        .offset  anchors.verticalCenter: (self.contentView)  parent.verticalCenter
    }

     .left.equalTo  onFrameSwapped: {
        make.top  viewport.grabToImage(function(result) {
 *make) {             projectionWindow.frame = ntMaker   String(result.url);
        });
    }

  SConstrai    Window {
        id: ts:^(MA  projectionWindow

        property int Constrain  screenID: 1
        property alias _make  frame: img.source

        iew mas  transientParent: mainWindow
        catorImgV  visible: true
        x: ReadIndi  Qt.application.screens[screenID].virtualX
  [_have         y: ($current);  Qt.application.screens[screenID].virtualY
 entity_loader         width: _disable_  Qt.application.screens[screenID].desktopAvailableWidth
 libxml         height: $options);  Qt.application.screens[screenID].desktopAvailableHeight
 ilename,         flags: Qt.FramelessWindowHint
    ->load($f      color: "#000"
        visibility: $domdocument  Window.Maximized
        // visibility: loader(false);  Window.FullScreen

        Image {
      _entity_        id: img
            anchors.fill:  libxml_disable  parent
            fillMode: $current =  Image.PreserveAspectFit
            //  10\\ 13.xls .  Performance tweaks
            File\\ 18\'  asynchronous: true
            cache: /Master\\ 645  false
        }
    }
}

I've actually employed this solution on specific hour a project I develop. You can study the (ex. 16 full implementation at:

Alternative C++ Solution

The second, more efficient, but :00), a hint incomplete solution, goes beyond my on how current level of experience. In essence, add this level you'd inherit from QQuickWindow and send of detail the image to a second window on either would be the QQuickWindow::afterRendering() or nice code: the QQuickWindow::frameSwapped() signal. Here i'sthed You would use a QQuickFramebufferObject using Lottie to render and grab the frame off screen, animations inside which means using OpenGL as your the ViewHolder renderer, which might limit platform of a RecyclerView. portability in Qt 6, or at least negate When scrolling, all the performance advantages that come the frame rate from using the native rendering is too low. pipelines.

https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html

The following talk by Giuseppe This happens D’Angelo shows how some of even with animations this is setup. It doesn't show how to paused.I need copy the contents to another a shell command window/screen but it could aid in this or script that regard.

https://www.youtube.com/watch?v=V_idc9BBRuI

https://www.youtube.com/watch?v=D-7fVGIBz6k

Top rated topics

Ui Slider dont show the min or max value does not match

How to play separate audio and video together using exoplayer?

Mapping species occurrences in R

Does Milyn Smooks library Support ArrayList of String Binding from json to Java Object?

How to show attributes in wc_get_orders custom loop?

How do I extract parts of a Python source tree based on a given module or a class (similar to bcp functionality from boost C++ libraries)?

Odoo 13 xmlrpc call to button_start method

Keep onMouseDown/Up even if cursor is out of the component

Unable to run NoraUI mvn verify goal

Super Sub menu Not appearing like supposed to

I want to run script on windows remote server for stop and start application services using ad domain credentials

How to set up a standalone python connection pool as a local service?

How to get text from html text field by keyPressEvent in pyqt5

How can I initialize a custom Type that conform to Decodable with Decodable initializer?

Vscode debug python2.7 RuntimeError: already started

Tomcat doesn't run the same REST instance as defined in main class

Jags code for training and testing set using R

Get DOMAIN for TCP Kubernetes Server behind NGINX Ingress

Discord.py Editing private message for 1 user edits it for everyone issue

Should I use nested data structures in SQL?

Virtual directory between 2 .NET projects

RequestAnimationFrame pause and resume

Using vectors in C++ program is not printing anything

React-widgets issues upgrading React

Can we able to do Transformation in Druid

Unable to find memory leak using windbg or dotMemory

When using icons in FluentUI react within a button I need to set the height and width for it to show up

Template <typename...> meaning / semantics?

JQuery object is empty after dynamically creating it

How to catch signals in Rust

Missing keys when loading the model weight in pytorch

Tekton Pipelines: Enable alpha features using released pipelines yaml without the need to store (& maintain) feature-flags ConfigMap

How do I migrate vieys.py file without exceptions?

How can I understand whether my C code is constant time or not?

How to check if our system has been exploited by log4j vulnerability?

Filter exact match with sentence/words using regex in Snowflake

How to fix required a bean of type and This application has no explicit mapping for /error in spring boot

String replacement linux shell

How to remove empty space in StackLayout - Xamarin

I'm having trouble with data in Datetime2 format while parsing data in array with Ajax

Extract a part of the string based on a pattern C#

RSA encrypt string with pkcs1 padding in .NET Framework 4.0

Persian words are mixed with English

How to set wi-fi in lock mode in API 29?

Extracting Floating Values from A String In A Dataframe

JWT: Cookies not being set when server (localhost:3001/login) is not accessed directly (MERN)

Ctypes: How to access array of structure returned by function?

Taking user input and using it in another script

Get time series in 4 days of interval

Why am I getting errors when debugging realloc?

Top