I have a Qt 4.8 application for both Win and Mac that captures the screen.
I have a QT widget on my desktop (always on top) that shouldn't be captured during my capture. Instead of the QT widget, the application/desktop running behind the QWidget should be captured. My QT application's UI should be masked from capturing.
Is there any way i can do this?
The main question is: are you in control of taking the screenshot or not? If you're taking the screenshot, it'd be doable but platform specific. You'd need to get the contents of all of the windows on the screen except the one you don't want to see, and build up a screenshot from those.
If it's a third party screen grabber, like Ctrl-PrtSc on Windows or Grab on OS-X, then you're out of luck unless the OS provides some APIs that would enable you to hide the widget.
The functionality you desire isn't exactly commonplace so I'm doubtful there's any portable, or even sane, way of achieving what you want.
Related
Because of display up to 4 UDP/RTP streams in different modes (single / dual / quad) I first decided to use GStreamer. It works but it is not easy to handle and I can not switch between viewing modes during runtime. To solve that issue I want to use Qt (5.12.4) with QML.
I read a lot about the integration of GStreamer in Qt (QGStreamer, QMediaPlayer), different GStreamer plugins (qmlglsink) and so on. At the end of the day I always end by the QMediaPlayer which integrates since Qt 5.12.x a gst-pipeline element.
I realized a Qt-QML application that show 4 UDP/RTP streams as a kind of preview and when I choose one of this previews it changes to full screen mode. A further tap on the full screen image changes back to preview mode.
BUT the performance is not really satisfied. Either one ore two previews are frozen and when I tap them the full screen is working or the preview is running and the full screen is frozen.
This leads me to the questions:
Is there a performance issue with my embedded device? -> I will check that soon. I can exclude a bandwith problem because only GStreamer works.
Is MediaPlayer with gst-pipeline the right way?
Are there other solutions with more performance using Qt with QML?
Thanks.
I'm working on a program in QT Creator as well as in QT Designer. This is my first experience with the QT family, and I've been working on this for about 3 weeks now. I have to design a variety of menus for a study I've been assigned to make this thing for.
I'm using the QT Designer / QT Creator built-in drag-and-drop to make the biggest pieces and then using code to change some things during runtime (some rich text labels change after user input, for example). My problem is that I'm working on a two-monitor setup. One monitor is 1920 by 1080, and the other is 3840 by 2160. When I drag the running program from the 1920/1080 screen to the other, the sizing just goes all to hell. Text in the LineEdit gets cut off and often the labels just get screwy.
I'm using the "QT Widget Application" project as a base in QT Creator and all of the UI forms are .ui files, NOT .qml files. I have a substantial portion of this already done, so I need to either keep everything in .ui while fixing this or find an easy way to convert to a better format AND fix the problem.
What's very weird is that QT Designer's preview screen of the form looks the same on both screens. I can drag the main menu preview between the 1920/1080 screen and the 3840/2160 screen and there's only very minor changes. Meanwhile the running program in QT Creator has massive disparities in appearance depending on the screen.
Here's a picture to hopefully explain it better, visually:
These are just two print-screens, cropped down to show one of the things that's changing. The top half is the running program, and the bottom half is the preview, both on the same screen at the same screen size (maximized). I've tried changing the horizontalStretch and verticalStretch for various elements in the Designer but it's still borked.
This is probably a rookie problem, but I am in fact a rookie with QT. I'm just trying to make sure that no matter what screen size we run this thing on, it looks the same no matter what.
Looks like a problem related to widget themes in Qt.
Qt Designer shows you the form preview using the fusion style, but when you run your program Qt will select the best match for your platform. This could explain the differences that you see. You can override this behavior forcing the fusion style.
Edit: Another thing that you can try is to enable the Hi-DPI screen support for rendering, if not set yet.
Just add this line to your main function like this:
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setStyle(QStyleFactory::create("Fusion")); // these lines before the next
QApplication a(argc, argv);
You will need to add #include <QStyleFactory> on top to make it work.
For anyone who's facing the same issue and using PyQt. Here's the solution.
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
app = QtWidgets.QApplication(sys.argv)
You just need to set an environment variable :)
Other than trying to manually, re-write everything to mimic the tooblar graphics and the size transition animation when moving between pages, Is there a better way to do this?
Amazingly I can't find ANY resources covering this, or even someone asking for this.
http://qt-project.org/doc/qt-5.1/qtwidgets/qtwidgets-index.html#styles
The window animations may already work as is... You may want to specify Native Windowing, so that the Mac Windowing system is aware of your Qt windows:
http://qt-project.org/doc/qt-5.1/qtwidgets/qwidget.html#native-widgets-vs-alien-widgets
Native Widgets vs Alien Widgets
Introduced in Qt 4.4, alien widgets
are widgets unknown to the windowing system. They do not have a native
window handle associated with them. This feature significantly speeds
up widget painting, resizing, and removes flicker. Should you require
the old behavior with native windows, you can choose one of the
following options:
Use the QT_USE_NATIVE_WINDOWS=1 in your
environment.
Set the Qt::AA_NativeWindows attribute on your
application. All widgets will be native widgets.
Set the
Qt::WA_NativeWindow attribute on widgets: The widget itself and all of
its ancestors will become native (unless
Qt::WA_DontCreateNativeAncestors is set).
Call QWidget::winId to
enforce a native window (this implies 3).
Set the Qt::WA_PaintOnScreen
attribute to enforce a native window (this implies 3).
See also
QEvent, QPainter, QGridLayout, and QBoxLayout.
And this link has more information on the styling in Qt than I have ever seen before today!
http://qt-project.org/doc/qt-5.1/qtwidgets/style-reference.html
Hope that helps.
I am not an expert but I have been using Qt/QtEmbedded for sometime now, for SBC 6845. I have created a few applications and have successfully run them on my device.
Now I want all of those applications to appear on a home screen. I understand that using QML/Qt Quick this might be achieved, but I don't have any idea on how to proceed with it. I have gone through some links and tutorials but most of them show how to create buttons and all that with Qt Quick, but not much than that. I am yet to find some tutorial/docs which can point me how to proceed with all applications on my home-screen. I need some directions, any links, advice on docs/books is welcome.
[While cross-compiling the QtEmbedded 4.6.2 libraries for my SBC I encountered problems with enabling opengl support. And, I am unaware of the other methods for using QtQuick2 without opengl.
The applications (5-6 of them) are QWidgets and linking icons require to stay in the home screen. I want to keep them as simple as possible without any effects for the icons.
Plainly speaking, I am trying to create a bunch of icons displayed on the home screen linked to those applications. The applications if launched in windows style application, (or like a popup QDialog) will also serve my purpose.]
Thanks.
"I have gone through some links and tutorials but most of them show
how to create buttons and all that with Qt Quick, but not much than
that"
For this part of the question, I'd advise you to download QtCreator
and start playing with the demos (using more than just some buttons:
you have demos for ListViews, GridViews, Delegates, Animations,
Particles, QtQuick Layouts (Qt5.1 only), QtQuick Controls (Qt5.1
only).
There's also the rather complete :
http://qt.gitorious.org/qt-labs/qt5-everywhere-demo
I'm completely unfamiliar with all the embedded/cross-compiling
aspects of your question.
About OpenGL/QtQuick2 : http://qt-project.org/forums/viewthread/30483
http://qt-project.org/forums/viewthread/17201
Also note that you can embed QtQuick2 scenes into a QWidget, but not
the other way around (no QtWidget inside the scenegraph).
So maybe the easiest/fastest way to go for you would be to stick with Qt4 or Qt5 declarative/QtQuick1 module (might be deprecated/removed starting with Qt 5.2). In this setup, there is no scenegraph/mandatory need for OpenGL. And you can embed QWidgets into your qml scene (no scenegraph: it uses the QGraphicsView backend) via QGraphicsProxyWidget.
You'd then have some GridView (you also could use some Grid with a Repeater) filled with models and delegates (= a delegate acts as a template item to be filled with the model).
Your delegates would have states/maybe Loader(s) (for on-demand loading) : icon state and when clicked, some maximized state containing a loader, loading your widget through QGraphicsProxyWidget.
You already have half of this presented in this example (a grid + 2 states : small icons grid and maximized view, you only need to implement the delegate/loading/model/QGraphicsProxyWidget things):
http://developer.nokia.com/Community/Wiki/Implementing_parent_change_animation_with_QML
I have enabled qt+OpenGl+SimpleGl on one of the ARM platform and was able to run opengl example programs.
I also has a qt+Webkit, which is working with a graphic plugin.
I wanted to use simpleGl context for every thing, instead of using the normal graphic screen. So, when I try to run Qt+Webkit with simpleGl, I just get a blank screen.
Does QT support this? If so how can we make it?
Yes, this is correct. OpenGL draws directly to the framebuffer. The simplegl driver doesn't handle what is drawn using the raster paint engine of the QWS, so you may see only black.
Using simplegl for "everything" means you want everything to be drawn using OpenGL in your EGL full-screen window? This is possible under some assumptions. You have to write all your applications to be rendered using the Qt OpenGL paint engine (using the opengl graphics system is not supported under Qt/E). This is possible also for QtWebKit, I'm doing it now. Note that this does not mean that everything is rendered using hardware acceleration. You'll have to write your applications "the right way" to get all actually hardware accelerated. Consider that you'll have to handle the mouse pointer some other way in this case.
The other way is to just modify the simplegl driver to allow for the use of Qt applications using the raster paint engine. This is possible as well with some limitations. Qt can use blit to place its own windows over OpenGL. Look for the framebuffer driver inside the Qt source tree to know how to do this. You can then have common Qt applications and OpenGL Qt applications some way. I'm doing this as well. Not everything can be done anyway.
EDIT: I'm sure you already did, but in case, give this http://doc.qt.io/qt-4.8/qt-embeddedlinux-opengl.html much attention.
Unfortunately I don't know anything about SimpleGL, but I do know that there is a way to render a standard Qt widget in a QGLWidget. Maybe have a look at this Qt Quarterly which I think is somewhat related to your question:
http://doc.qt.nokia.com/qq/qq26-openglcanvas.html