My Qt application (that will run on Windows, OS X and Ubuntu) has a need to:
List all windows everywhere
Obtain their caption text (if any)
Obtain an Icon of the application, if any, as QIcon or QPixmap (e.g. App Icon)
Obtain some kind of unique ID about them (e.g. HWND on windows)
I know how to do this for Windows using Win32. I can research Mac and Ubuntu separately, but I was wondering if there's an abstracted/unified Qt approach to assist me?
Nope, those are OS specific:
http://www.qtcentre.org/threads/41730-How-to-enumerate-all-top-level-windows
As for starting down the quest of what's doable through published APIs...some X11 hints here:
How to identify top-level X11 windows using xlib?
On Macs, the "forward-looking" way to build Qt is against "Cocoa" instead of "Carbon":
http://doc.qt.nokia.com/latest/developing-on-mac.html#carbon-or-cocoa
And according to other SOers, it's the accessibility API (which has to be enabled by users, it seems) that can do this enumeration:
Get a list of opened windows cocoa
Mac / Cocoa - Getting a list of windows using Accessibility API
Then the question becomes how inside of a C++ application to make "calls out" to Cocoa APIs which are natively Objective-C:
How to mix Qt, C++ and Obj-C/Cocoa
...or you could just not do this. :-)
I would suggest keeping track of this information yourself. It wouldn't be perfect (just have a singleton class and overload the setWindowTitle() calls in your root window types) but would be platform-independent . . .
Related
In Qt Creator it is possible to run the program clicking the green play button (using PySide6), but not edit the qml file in Design mode, where it gives the error "Line 0: The Design Mode requires a valid Qt kit" inside the design view. I created a project and selected Qt for Python (qml).
But I have installed several gb of the newest Qt version during installation? I have also selected the correct python env in the options.
When I create a non-qml project, but add a .qml file later a popup error says:
"The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old or it cannot run natively on your computer. The fallback emulation layer, which does not support all features, will be used"
The Qt version is 6.2.2 and the OS is Windows 11. It is possible to use design mode in Qt Design Studio.
I meet the same problem and my environment is similar, choose Edit → Preferences and enter the Kits. Then select a Qt version and a kit you like (the type of qmake shall be the same, for instance, both of them is msvc), and remember to apply the changes.
After that, go back to the form editor and it works well. What confused me is that I must repeat the steps above each time I want to use Qt, the config seems to not be saved correctly. (The Qt version is 5.1.2 and the OS is Windows 11)
PS: After selecting the kit, you need to restart Qt.
As Qt application will be in native look and feel.
I want to get mac look and feel for my Qt application. Is it possible to do so?
It is possible to change look and feel of Qt application by using styles:
QApplication::setStyle("macintosh");
List of available styles is given by:
QStringList list = QStyleFactory::keys();
But for example on Windows Mac style is typically unavailable. I tested on Windows machine with Qt 5.4 - only Windows (Windows, WindowsXP and WindowsVista) and Fusion styles are available - you can switch between them.
Of course, Windows style is default for Windows. It is advised to set style before constructing QApplication.
I'm developing a Qt Widgets application and due to compile performance issues, I started developing it in Linux Ubuntu instead of Windows. The problems is that, when compiled and run, the app appears with traditional Ubuntu style instead of Windows (7) style. Since the app is only for Windows, I'ld like to know how can I compile it inside Linux Ubuntu but making it appear with Windows style.
I tried using QApplication::setStyle(QStyleFactory::create("QWindowsStyle")); in main.cpp, without success. I guess the QtAssistant docs just aren't clear enough on how can I do this change. Any help will be appreciated.
Could you by any chance be using a Qt package that is compiled without the style? Can you try running QStyleFactory::keys() to verify that the style exists?
It can't be done, since the style's elements are rendered by Windows (or OS X), not by Qt. Qt's style implementation asks the OS libraries to provide bitmaps of those elements. If you wanted to, you could modify the style to use a disk cache for static items. You could then use the style on all platforms. The problem is that these OS-provided bitmaps are a part of the OS and thus non-redistributable.
The only plastform-specific style that at least used to be available everywhere was the old Windows 95 style, in times of Qt 3. I'm not sure what its current status is.
First check out put of QStyleFactory::keys()
then set the look by calling
qApp->setStyle("Windows");
This command will give you windows 98 look. If you want windows vista look you should configure qt sources with -style-windowsvista and rebuild all sources.
UPDATE
according to http://doc.qt.io/qt-5/qstylefactory.html#details qt style is not platform independent. So IT IS IMPOSSIBLE to have that native look in not windows platform. It's worth mentioning that in windows also Windows SDK itself is required in order to build sources of Qt otherwise your application will look like windows 98 in windows 7.
I am using Qt in order to build a cross platform GUI app (Windows and Mac). I want to be able to update the app efficiently and automatically whenever there is a new patch available.
I saw this post which got me to take a look at WyBuild. It looks great and probably what I may end up using for the Windows version but what about Mac? What are some alternatives available to me?
I've just started developing a Qt-based autoupdater called Fervor for my own needs. You can try it out, contributions are more than welcome too.
For Mac the best choice is Sparkle used by WebKit, Adium, Cyberduck and more. Its only for Mac but I guess native look matters on Mac a lot.
Not familiar with WyBuild so cannot comment. Sparkle is a fine choice but the poster preferred a single app for both platforms. BitRock InstallBuilder contains an autoupdater written in Qt that can be used independently (disclaimer, I am the original BitRock developer). It is a commercial app, but we have free licenses for open source projects.
There is Updatenode which seems to provide a real Qt cross-platform solution.
It comes with a prebuilt client for Windows, Mac and Linux. The online service lets you manage updates very easy and are able to see good charts of your application usage.
And here another one of the possibilities:
Using the Qt Installer Framework: It provides installers for Windows/Linux/Mac with an build-in updater. If you need an example - The MaintenanceTool of your Qt-Installation uses the framework.
To get an auto-updater from it, all you need to do is:
Create an online installer (Just check the documentation, it's not that hard)
Use the maintenancetool in your application to check for updates.
This cane be done using my QtAutoUpdater. Go there for more information about the whole process
If new updates are available, the maintenancetool can be started in updater mode to install the update
Update the online repository - and your update is out.
Advantages:
Installer and updater in 1 tool - this means less work for you
Easy to use (with or without the QtAutoUpdater library)
Cross-Platform for all desktop platforms supported by Qt
The installer itself is a Qt original
Disadvantages:
No "native" installers (i.e. no .msi on windows or .deb on ubuntu)
Must be used together - if you want to use the update feature, you have to use the framework as installer
This may be obvious, but for Linux you can use the built in package manager. For example, apt-get, yum, pacman, or what have you.
Windows 7 Aero Theme has a brand new taskbar with extensions.
What is the current status of Taskbar Extensions (jump lists, etc.) support in Qt?
Far as I'm aware there's no support for this yet - but there would be nothing to stop you making native OS API calls to do this just on Windows.
If you want to see an example of this approach, check out this recent Qt Labs posting about using "blur-behind" on windows.
There is a commercial Qt add-on that implements all the taskbar extensions. It is called Q7Goodies and it seems to be really easy to use.
I've written a small library for Qt, it just provides support for progress bar and overlay icons on the new Windows 7 taskbar. You can find it on my blog. Obviously it is free to download and use.