【问题标题】:Qt5.6 RHEL Fullscreen application window and child windowQt5.6 RHEL全屏应用程序窗口和子窗口
【发布时间】:2016-04-28 08:30:22
【问题描述】:

我正在编写一个 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
    }

模拟窗口中的构造函数sn-p:

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

这不是所有的代码,但希望足以说明我做了什么以及问题可能出在哪里?

【问题讨论】:

    标签: c++ window qt5.6


    【解决方案1】:

    通过将调用移动到构造函数之外的显示方法来修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 2014-08-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多