I want to start an application on fullscreen (MacOS 10.8.x, Qt 5.1.1, C++) depending on the settings:
main.cpp
#include "MainWindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.showFullScreen(); return a.exec(); }
MainWindow.cpp
#include "MainWindow.h" #include "ui_MainWindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; }
MainWindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
The settings comportment is perfect, works like a charm. But this->showFullScreen()
does something very ugly :
How to avoid this?
Use double click to reveal the element on the full screen. Use {Esc} to return to the layout.
Press Ctrl+F and type "maximized"
This article will show you step by step how to make a widget full screen. By default, the widget pop-up only takes up part of the screen. It is now possible to make widgets full screen. Go to the "Settings" tab > Click on "Widgets" > Select "full screen" in the pop up dimension.
I already faced this problem and a very nice solution was to delay the fullscreen switch by one second (using a QTimer):
QTimer::singleShot(0, this, SLOT(showFullScreen()));
use the following if you want to have the app open as maximized window:
Mainwindow w; w.setWindowState(Qt::WindowMaximized); w.show();
use the following if you want to have the app open as fullscreen window:
Mainwindow w; w.setWindowState(Qt::WindowFullScreen); w.show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With