Search code examples
c++qt5.5

Compilation issue with qt_screen


I have Qt5.5 Installed on Desktop PC On Ubuntu OS.

While compiling my program i am getting below error -

This is what i got for error

../../work/mainwindow.cpp: In constructor 'MainWindow(QWidget)': 
../../work/mainwindow.cpp:63:31:
error: 'qt_screen' was not declared in this scope ui->stackedWidget-
>resize(qt_screen->deviceWidth(),qt_screeb->deviceHeight());

And this is part of my code

MainWindow::MainWindow(QWidget *parent) : 
QMainWindow(parent),
ui(new Ui::MainWindow)
{
  ui->setipUi(this);
  setWindowFlags(Qt::CustomizeWindowHint);
  ui->stackedWidget->resize(qt_screen->deviceWidth().qt_screen->deviceHeight());
  ui->stackedWidget->setCurrentWidget(ui->stackedWidgetPageMain);

  initPageMain();

  touch=new Touch();
  powerButton=new PowerButton();
  auxButton=new AuxButton();
  usbOtg=new UsbOtg();
  battery=new Battery();
  panel=new Panel();
  lan=new Lan();
  hPattern= new HPattern();
  lodLog=new LodLog();
  record=new Record();
  led=new Led();
  lightsensor=new LightSensor();
}

Did i miss to include anything?

By the way i'm sure that i had include Qscreen into it.

Is there any possibility that i might set wrong on my code?


Solution

  • QScreen class has changed notably from Qt4 and Qt5, actually so much, that it is considered new in Qt5.

    Qt4 QScreen had a static method called QScreen::instance() which returned a QScreen instance pointer. Way back in Qt4, this pointer was taken from a global variable qt_screen, if I remember correctly. All this has changed, so simply remove all code which access qt_screen and fix it by properly accessing public APIs.