c++qtubuntu-16.04fullscreenqinputdialog

qInputDialog make visible Unity taskbar and titlebar in fullscreen application


I'm trying to ask for a password the user in order to access a particular section, my application is fullscreen. The problem is that when the qInputDialog appears also the unity taskbar and the application titlebar appears. I want to avoid this and keep my application fullscreen. I'm using Qt 5.12.3 on Ubuntu 16.04

Take a look at this simple example:

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"

#include <QInputDialog>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    bool ok;
    QString text = QInputDialog::getText(this, tr("Restriscted"),
                                         tr("Password:"), QLineEdit::Password,"",&ok, Qt::FramelessWindowHint);
    if (ok && text=="pass")
    {
        ui->label->setText("ok");
    }
}

Solution

  • Seems there is no solution for this at the moment and the issue depends on Unity. At the end I replaced the qInputDialog with a qStackedView page with a qLabel and a qButton on it, then I hide/show the page accordingly.