1
我試着去製作一個小工具,它具有在啓動時使即時通訊做被隱藏:QMessageBox提示後,Qt的主窗口退出關閉
上的main.cppw.showMinimized();
w.hide();
這就要求我的主窗口中的一個隱藏的模式,但問題是,當我叫FinishSession()這是對類ProductDlg這是從課程的主窗口調用的函數,它時,我點擊「是或否」從QMessageBox提示您看到波紋管
void ProductsDlg::FinishSession()
{
if(Session)
{
if(this->isActiveWindow())
{
this->hide();
}
QMessageBox::StandardButton _finishSession = QMessageBox::question(this , "Question" , "Do you wanna Finish the Session ?" , QMessageBox::Yes | QMessageBox::No); // THIS MESSAGEBOX - IT EXISTS AFTER THIS
if(_finishSession == QMessageBox::Yes)
{
Session = false;
}
}
else
{
qDebug() << "No Session is Running";
}
}
這是存在從MainWindow.cpp,我打電話ProductsDlg:
bool MainWindow::nativeEvent(const QByteArray &eventType , void *message , long *result)
{
Q_UNUSED(eventType);
Q_UNUSED(result);
MSG * msg = static_cast<MSG*>(message);
if(msg->message == WM_HOTKEY)
{
if(msg->wParam == 0)
{
if(!pd->isVisible())
{
QRect rect = QApplication::desktop()->availableGeometry();
pd->show();
pd->setFocus();
pd->activateWindow();
pd->move(rect.width() - pd->width() , rect.height());
QPropertyAnimation *ani = new QPropertyAnimation(pd , "pos");
ani->setDuration(700);
ani->setStartValue(pd->pos());
ani->setEndValue(QPoint(rect.width() - pd->width() , rect.height() - pd->height()));
ani->start();
}
else if(!pd->isActiveWindow())
{
pd->activateWindow();
}
else if(pd->isActiveWindow())
{
pd->hide();
}
}
else if(msg->wParam == 1)
{
pd->FinishSession();
}
else if(msg->wParam == 2)
{
if(pd->isActiveWindow())
{
pd->hide();
}
}
else
{
return false;
}
}
else
{
return false;
}
}
「pd」是全局定義的,並在MainWindow構造函數中初始化。