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?


  • Lifetime Qt Champion

    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();
    }
    

  • Moderators

    @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
    0_1487838222101_help.png

    So i don't think it is the problem.



  • @jsulm Something wrong in this code ?
    ui->stackedWidget->resize(qt_screen->deviceWidth().qt_screen->deviceHeight());


  • Lifetime Qt Champion

    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.


  • Moderators

    @Hung-Tran The error message actually tells you what is wrong. qt_screen is not declared.
    Add

    private:
    QScreen qt_screen;
    

    to your MainWindow class.



  • @jsulm
    It doesn't work and more error now.
    This is what i got for my error

    0_1487840442678_help.png

    I have tried to add this function

    QScreen *qt_screen;
    

    But actually it won't work because deviceWeight() is not the member.
    Still got error.


  • Moderators

    @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.



  • @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.


  • Lifetime Qt Champion

    Following what you wrote, it looks like you should rather take a look at QDesktopWidget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.