What is the difference between Q_WS_* and Q_OS_* in Qt and when would you use one over the other? I understand that OS is defined on an operating system, and WS is defined for a window system, but I can't see when you'd use one over the other. Wouldn't Q_WS_MAC and Q_OS_MAC be the same, for example? What's the general rule and could I have some example use cases for each?
Simple. You use Q_OS
flagging when you need operating system specific code and Q_WS
when you need window system specific code.
As an example, UI for Maemo devices (Q_WS_MAEMO_5
) often needs to be different from Linux desktop but both are still Q_OS_LINUX
.
As you know, WS is for Window System, whereas OS is for Operating system. Under Q_OS_MAC, you could be running Qt with Q_WS_X11, for instance.
Unless you're testing for some feature (or defect) specific to a WS, you probably are looking for OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With