Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to make the contents in central and make the window fullscreen?



  • Hi, I want to make a application that have some windows.I have two questions.
    One:
    The windows are all default size when i run it . I want to make it fullscreen. I have found a method which is
    Mainwindow w;
    w.setWindowState(Qt::WindowFullScreen);
    w.show();
    That works but the problem is the Exit option(I mean the cross) gets vanished. How can i make the window fullscreen by keeping the exit option.
    Two:
    When it becomes fullscreen the contents like lable, pushbutton, messagebox all are displaced.How can i centralized the contents when i make the window fullscreen.
    It will be very kind if anyone can help me with this.


  • Lifetime Qt Champion

    Hi,

    Then don't make it full screen but resize it to take the screen size. You can use showMaximized for that.

    As for your widgets, are you using layouts to place them ?



  • In some cases there are layouts and in some there is no layout. I used layout for the pushbuttons . But i didn't use it for labels.
    Thanks for the maximized option it works perfectly.



  • Hi,

    Why can't you use Qml Qt Quick application for your application development it was fully OpenGL , helps you to works application smoothly and Sharp finishing to the application.


  • Lifetime Qt Champion

    @Kiranachari-Shilpi how is that related to the question at hand ?



  • Give fixed size for your widgets like pushbutton , label and message box and since you are using Mainwindow place all these widgets in the centralwidget by using setcentralwidget() so that they will be placed correctly and if u want to maximize your window use showMaximized()


Log in to reply