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

时间:2016-04-28 08:30:23

标签: c++ window qt5.6

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

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

    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();
    }

这不是所有代码,但希望足以显示我所做的以及问题出在哪里?

1 个答案:

答案 0 :(得分:0)

通过将调用show方法移到构造函数之外来修复。