#include "MainWindow.h" #include "ui_MainWindow.h" #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QVBoxLayout *vlayout = new QVBoxLayout(); ui->centralWidget->setLayout(vlayout); QDesktopWidget *desktop = QApplication::desktop(); QLabel *descLabel = new QLabel(QString("This %1 a virutal desktop with %2 screens").arg(desktop->isVirtualDesktop() ? "is" : "is not").arg(desktop->screenCount())); vlayout->addWidget(descLabel); m_locationLabel = new QLabel(); vlayout->addWidget(m_locationLabel); updateLocation(); } void MainWindow::updateLocation() { m_locationLabel->setText(QString("I am on screen %1").arg(QApplication::desktop()->screenNumber(this))); } MainWindow::~MainWindow() { delete ui; }