我正在编写一个 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();
}
这不是所有的代码,但希望足以显示我做了什么以及问题可能出在哪里?