Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Check platform type : Mobile or Desktop

I'm looking for some code I could use to check if my application is executed on a mobile/tablet or a computer. Here is a sample to explain what I'm doing :

#include <QtGlobal>

#if defined Q_OS_BLACKBERRY || defined Q_OS_ANDROID || defined Q_OS_IOS || defined Q_OS_WP
#define Q_OS_MOBILE
#else
#define Q_OS_DESKTOP
#endif

How does it look to you? Am I reinventing the wheel?

like image 535
StEvUgnIn Avatar asked Mar 02 '15 13:03

StEvUgnIn


1 Answers

The reason there's no (to my knowledge) pre-fabbed #defines for this is the definition of mobile vs desktop vs embedded is blurry. For example Q_OS_QNX is set alongside Q_OS_BLACKBERRY, and Q_OS_DARWIN is set on both Q_OS_IOS and Q_OS_MACX. Similar problem for Q_OS_LINUX on Android, and then there's a range of confusion around Windows versions.

If the definitions you've suggested work for your use-case, I think that's a perfectly reasonable way to proceed. I maybe would use a different naming scheme to Q_OS_foo however.

like image 192
James Turner Avatar answered Sep 21 '22 23:09

James Turner