Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Q_WS_* and Q_OS_* in Qt?

Tags:

qt

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?

like image 250
Jake Petroules Avatar asked Nov 13 '10 06:11

Jake Petroules


2 Answers

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.

like image 52
laalto Avatar answered Sep 30 '22 20:09

laalto


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.

like image 29
OliJG Avatar answered Sep 30 '22 18:09

OliJG