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? -
Hi and welcome to devnet,
The upload feature is currently broken, please use an image sharing site so we can see what the problem is about.
-
@SGaist
Thanks for telling me .
This is what i got for my 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(); }
-
@victor-wang What is qt_screen and where was it declared?
-
@jsulm
I thought that qt_screen no need to be declared.
Because when i get this Sample codeļ¼ it doesn't seem to be declared.
According to that i search the Example code on Qt website, they do the same thing as below
So i don't think it is the problem.
-
A sample code is not necessarily a fully functioning example.
Also, it's C++, you can't use something that wasn't declared and depending on how you declared it, it also need to be initialized.
-
@Hung-Tran The error message actually tells you what is wrong. qt_screen is not declared.
Addprivate: QScreen qt_screen;
to your MainWindow class.
-
@victor-wang I cannot see the screenshot (images do not work here usually).
Did you include QScreen class in your MainWindow header?
deviceWeight() is not member of QSreen this is correct. I guess the example you're using is older?
Check the documentation: http://doc.qt.io/qt-5/qscreen.html
You need to use something else (http://doc.qt.io/qt-5/qscreen.html#geometry-prop ?).Note: QScreen *qt_screen; is not a function, it is variable declaration.
-
Following what you wrote, it looks like you should rather take a look at QDesktopWidget.