I'm trying to implement accessibility for my Qt application. I'm using NVDA (http://www.nvda-project.org/) and Freedom Scientific's JAWS (http://www.freedomscientific.com/products/fs/jaws-product-page.asp) as the screen readers I want to support.
I'm assigning the widget's accessibleName and accessibleDescription properties (http://doc.trolltech.com/4.7/qwidget.html#accessibleDescription-prop) in order to get the screen reader to read this information.
Example:
saveButton->setAccessibleName("save");
saveButton->setAccessibleDescription("Save the options you have entered above");
In both screen readers everything is working correctly when using the mouse. However, when focus changes in a widget all the readers read is "pane". Why isn't Qt providing the accessibility information that I need?
You have to import a plug-in to get Qt to have accessible widgets. This lets screen readers read the names, and hierarchies of objects.
To get this, you need to add qtaccessible widgets to your qmake project file:
QTPLUGIN += qtaccessiblewidgets
And in main.cpp add a Q_IMPORT_PLUGIN
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
Then screen readers will be able to accurately read:
"Button. Save. Save the options you have entered above. Press space to activate the button."
When you tab to (or otherwise place focus on) a button
in a tutorial video I saw that Qt surface components
have the properties "AccessibleName" and "AccessibleDescription".
This suggests that Qt applications are screen readable
can be developed. In the programming languages are called Java and C #
the properties the same.
I am developing Python on Windows 10
Question:
Is there a guide on how to make a Python Qt application suitable for screen readers?
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 :)
I'm returning to Qt programming after an absence of a couple of years, and I'm starting with Qt 5.1. In the past, I've used the designer, and a good deal of hand-crafted code to put Qt projects together. Now, we'd like to make heavy use of the Creator.
But I'm not seeing how to accomplish some seemingly basic tasks. For example, I'd like to design a custom widget, then pull it into my main application, but although the Creator allows me to make multiple files within a project, they seem to have no knowledge of one another as far as the Creator itself is concerned. Once my widget is built, there's no way to pull it into the main application, and also no way to test it independently, at least that I'm able to find.
It seems as though documentation for Qt has taken a major blow somewhere along the line. It is cursory and thin, compared to the extremely detailed docs that used to be available in the past.
If someone can point me to a decent collection of documentation and tutorials, I would be grateful.
Unit Testing
Use the Qt Test module: https://doc.qt.io/qt-5/qttest-index.html
Using Custom Widgets
I'm not 100% sure what you meant by "pull [the widget] into the main application".
If you want to combine your custom widgets in Qt Designer, add a placeholder (blank) QWidget in the parent and Promote it to your custom widget:
https://doc.qt.io/qt-5/designer-using-custom-widgets.html#promoting-widgets
If you want to combine your custom widgets in C++, instantiate your custom child widget and add it into the parent widget's layout using QLayout::addWidget():
https://doc.qt.io/qt-5/qlayout.html#addWidget
If you want to make your application display a custom widget, simply #include the widget's header, instantiate the widget, and call QWidget::show():
https://doc.qt.io/qt-5/qwidget.html#show
If you want to develop your custom widget in a separate standalone project, include it in your main project as a Subproject:
https://doc.qt.io/qtcreator/creator-project-creating.html#adding-subprojects-to-projects
How do I make a subproject with Qt?
Other Notes
Qt Designer has been integrated into Qt Creator for many years. Qt Designer and its documentation have changed very little between Qt 4.8 and Qt 5.
The extremely detailed docs for Qt 5 are at https://doc.qt.io/qt-5/. There are links to useful doc collections in the nav bar on the right.
I recommend exploring QML/Qt Quick. It's much easier to create QML-based GUIs compared to widget-based GUIs. It's still a young technology though, so it might not suit your needs yet: http://doc.qt.io/qt-5/qmlapplications.html
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 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.