优化Linxu窗口显示逻辑
This commit is contained in:
parent
f73df5adf5
commit
32e7e649ae
|
|
@ -15,8 +15,8 @@ ConnectionDialog::ConnectionDialog(QWidget *parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
if(QSysInfo::kernelType() == "linux")
|
if(QSysInfo::kernelType() == "linux")
|
||||||
{
|
{
|
||||||
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,去边框后是简单的解决上述问题的方法
|
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,因此需要去掉Dialog属性,随之而来的问题是,模态无法起作用
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() & ~Qt::Dialog);
|
||||||
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;}");
|
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;}");
|
||||||
}
|
}
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,8 @@ void MainWindow::showMessageDialog(MessageDialogType type,const QString& strTitl
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
||||||
// int nX = this->geometry().x() + (this->width() - m_pMessageDialog->width()) * 0.5;
|
int nX = this->geometry().x() + (this->width() - m_pMessageDialog->width()) * 0.5;
|
||||||
// int nY = this->geometry().y() + (this->height() - m_pMessageDialog->height()) * 0.5;
|
int nY = this->geometry().y() + (this->height() - m_pMessageDialog->height()) * 0.5;
|
||||||
// m_pMessageDialog->move(nX, nY);
|
|
||||||
QRect parentFrame = this->frameGeometry(); // 获取父窗口的完整几何信息(包含边框和标题栏),适用于快平台对其
|
|
||||||
int nX = parentFrame.x() + (parentFrame.width() - m_pMessageDialog->width()) / 2;
|
|
||||||
int nY = parentFrame.y() + (parentFrame.height() - m_pMessageDialog->height()) / 2;
|
|
||||||
m_pMessageDialog->move(nX, nY);
|
m_pMessageDialog->move(nX, nY);
|
||||||
//m_pMessageDialog->raise();
|
//m_pMessageDialog->raise();
|
||||||
// if(type == type_question)
|
// if(type == type_question)
|
||||||
|
|
@ -146,12 +142,12 @@ void MainWindow::onActionTrigger_connect()
|
||||||
connect(m_pConnectionDialog, &ConnectionDialog::addConnection, this, &MainWindow::onSIG_addConnection);
|
connect(m_pConnectionDialog, &ConnectionDialog::addConnection, this, &MainWindow::onSIG_addConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int nX = this->geometry().x() + (this->width() - m_pConnectionDialog->width()) * 0.5;
|
int nX = this->geometry().x() + (this->width() - m_pConnectionDialog->width()) * 0.5;
|
||||||
// int nY = this->geometry().y() + (this->height() - m_pConnectionDialog->height()) * 0.5;
|
int nY = this->geometry().y() + (this->height() - m_pConnectionDialog->height()) * 0.5;
|
||||||
// m_pConnectionDialog->move(nX, nY);
|
m_pConnectionDialog->move(nX, nY);
|
||||||
QPoint centerPos = this->mapToGlobal(this->rect().center());
|
// QPoint centerPos = this->mapToGlobal(this->rect().center());
|
||||||
centerPos -= QPoint(m_pConnectionDialog->width()/2, m_pConnectionDialog->height()/2);
|
// centerPos -= QPoint(m_pConnectionDialog->width()/2, m_pConnectionDialog->height()/2);
|
||||||
m_pConnectionDialog->move(centerPos);
|
// m_pConnectionDialog->move(centerPos);
|
||||||
m_pConnectionDialog->show();
|
m_pConnectionDialog->show();
|
||||||
}
|
}
|
||||||
void MainWindow::onActionTrigger_disconnect()
|
void MainWindow::onActionTrigger_disconnect()
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ MessageDialog::MessageDialog(QWidget *parent)
|
||||||
|
|
||||||
if(QSysInfo::kernelType() == "linux")
|
if(QSysInfo::kernelType() == "linux")
|
||||||
{
|
{
|
||||||
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,去边框后是简单的解决上述问题的方法
|
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,因此需要去掉Dialog属性,随之而来的问题是,模态无法起作用
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() & ~Qt::Dialog);
|
||||||
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;background-color:rgb(250,250,250);}");
|
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;background-color:rgb(245,245,245);}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ ModelInfoEditDialog::ModelInfoEditDialog(QWidget *parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
if(QSysInfo::kernelType() == "linux")
|
if(QSysInfo::kernelType() == "linux")
|
||||||
{
|
{
|
||||||
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,去边框后是简单的解决上述问题的方法
|
//Linux下默认的Qt::Dialog即使有父窗口也无法按照子窗口的行为进行展示,并且最大、最小按钮不好关闭,因此需要去掉Dialog属性,随之而来的问题是,模态无法起作用
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() & ~Qt::Dialog);
|
||||||
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;background-color:rgb(250,250,250);}");
|
setStyleSheet("QDialog{border: 1px solid rgb(205,205,205);border-radius:5px;background-color:rgb(250,250,250);}");
|
||||||
}
|
}
|
||||||
initialize();
|
initialize();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue