Qt5.6 RHEL 全屏应用程序 window 和 child window
Qt5.6 RHEL Fullscreen application window and child window
我正在编写一个 C++ Qt 应用程序,主要 window 占据整个屏幕,child window 包含模拟控件。
我正在使用 RHEL 7.2 和 Qt 5.6。问题是 child window 虽然在任务列表中可见,但在显示屏上不可见。
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
}
来自模拟的构造函数片段 window:
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++ Qt 应用程序,主要 window 占据整个屏幕,child window 包含模拟控件。
我正在使用 RHEL 7.2 和 Qt 5.6。问题是 child window 虽然在任务列表中可见,但在显示屏上不可见。
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
}
来自模拟的构造函数片段 window:
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();
}
这不是全部代码,但希望足以说明我所做的以及问题可能出在哪里?
已通过将显示方法的调用移到构造函数之外来修复。