Compilation issue with qt_screen
-
wrote on 22 Feb 2017, 10:03 last edited by victor wang
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.
-
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.
wrote on 23 Feb 2017, 02:23 last edited by@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(); }
-
@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?
-
@victor-wang What is qt_screen and where was it declared?
wrote on 23 Feb 2017, 08:25 last edited by victor wang@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.
-
@victor-wang What is qt_screen and where was it declared?
-
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.
-
@jsulm Something wrong in this code ?
ui->stackedWidget->resize(qt_screen->deviceWidth().qt_screen->deviceHeight());@Hung-Tran The error message actually tells you what is wrong. qt_screen is not declared.
Addprivate: QScreen qt_screen;
to your MainWindow class.
-
@Hung-Tran The error message actually tells you what is wrong. qt_screen is not declared.
Addprivate: QScreen qt_screen;
to your MainWindow class.
wrote on 23 Feb 2017, 09:06 last edited by@jsulm
It doesn't work and more error now.
This is what i got for my errorI have tried to add this function
QScreen *qt_screen;
But actually it won't work because deviceWeight() is not the member.
Still got error. -
@jsulm
It doesn't work and more error now.
This is what i got for my errorI have tried to add this function
QScreen *qt_screen;
But actually it won't work because deviceWeight() is not the member.
Still got error.@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.
-
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.
wrote on 23 Feb 2017, 09:13 last edited by@SGaist
I'm thinking if it is possible to use Qscreen to show the full screen?
I can use the other way to achieve my goal. -
Following what you wrote, it looks like you should rather take a look at QDesktopWidget.
1/12