Qt5.6 RHEL全屏应用程序窗口和子窗口

Qt5.6 RHEL Fullscreen application window and child window

本文关键字:窗口 应用程序 RHEL Qt5      更新时间:2023-10-16

我正在编写一个C++Qt应用程序,该应用程序具有占据整个屏幕的主窗口和包含模拟控件的子窗口。

我使用的是RHEL 7.2和Qt 5.6。问题是,子窗口虽然在任务列表中可见,但在显示器上不可见。

    clsMainWin::clsMainWin(QRect rctScr, QWidget *parent) : QMainWindow(parent)
                                                    ,ui(new Ui::clsMainWin) {
        ui->setupUi(this);
    //Set-up window container background and size
        setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
        setWindowIcon(QPixmap(1,1)));
        setGeometry(rctScr);
    //Display the window container
        showFullScreen();
    #ifdef SIM_WINDOW
        mpobjSimWin = NULL;
    #endif
    }
    void clsMainWin::paintEvent(QPaintEvent* pEvt) {
    //Prevent compiler warning!
        pEvt = pEvt;
    //Get painter context
        QPainter objPainter(this);
    //Fill the root area with the chosen colour
        objPainter.fillRect(geometry(),
            QColor(mpobjRoot->strGetAttr(mcszXMLattrColorBg)));
     #ifdef SIM_WINDOW
        if ( mpobjSimWin == NULL ) {
            mpobjSimWin = new clsSimWin(this);
            mpobjSimWin->setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
            mpobjSimWin->raise();  // for MacOS
            mpobjSimWin->activateWindow(); // for Windows
        }
    #endif
    }

模拟窗口中的构造函数片段:

    clsSimWin::clsSimWin(QWidget *parent) : QDialog(parent)
                                   ,ui(new Ui::clsSimWin) {
        assert(parent != NULL);
        ui->setupUi(this);
    //Set the window title
        this->setStyleSheet("background-color: white;");
        setWindowTitle("Data simulator");
    //Set-up window
        Qt::WindowFlags flags = (Qt::Window
                               | Qt::WindowTitleHint
                               | Qt::CustomizeWindowHint)
                              & ~Qt::WindowMaximizeButtonHint;
        setWindowFlags(flags);
        setFixedSize(mcintWindowWidth, mcintWindowHeight);
    //Display the window
        show();
    }

这并不是所有的代码,但希望足以展示我所做的工作以及问题可能在哪里?

通过移动调用以显示构造函数之外的方法来修复此问题。