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 :
I can provide a video if needed. How to avoid this?
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()));