auto label1 = new QLabel("some label", this); auto checkBox1 = new QCheckBox("set me", this); #if defined (Q_OS_ANDROID) auto layout1 = new QVBoxLayout; // Vertical layout for mobile #else auto layout1 = new QHBoxLayout; // Horizontal layout for desktops #endif layout1->addWidget(label1); layout1->addWidget(checkBox1); auto widget1 = new TTouchArea(this); widget1->setLayout(layout1); // The same for another widget (TtouchArea) auto widget2 = new TTouchArea; auto stack = new QStackedWidget; stack->addWidget(widget1); stack->addWidget(widget2);