Qt 下遇到的一些问题
Windows
warning::setGeometry: Unable to set geometry
- 设置窗口标记位 setWindowFlags (Qt::MSWindowsFixedSizeDialogHint);
- 设置它的最大大小和最小大小
//最小值
setMinimumSize(500, 500);
//最大值
setMaximumSize(500, 500);
- 使用setFixedSize()
注意这个方式会屏蔽掉最小化按钮,需要最小化按钮请使用
setWindowFlags (Qt::WindowMinimizeButtonHint);
QMessageBox弹出的对话框关闭后,整个程序退出
//Qt Assistant解释如下
void QGuiApplication::lastWindowClosed() [signal]
This signal is emitted from exec() when the last visible primary window (i.e. window with no parent) is closed.
By default, QGuiApplication quits after this signal is emitted. This feature can be turned off by setting quitOnLastWindowClosed to false.
quitOnLastWindowClosed : bool
This property holds whether the application implicitly quits when the last window is closed.
The default is true.
If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) is closed.
Access functions:
bool quitOnLastWindowClosed()
void setQuitOnLastWindowClosed(bool quit)
//解决办法 在QMessageBox弹出前加一句
QApplication::setQuitOnLastWindowClosed(false);
qt最小化窗口之后再次最大化,子控件不刷新的问题
拦截event事件,处理事件
bool LiveClientMainWidget::event(QEvent *event)
{
qDebug() << "bool LiveClientMainWidget::event(QEvent *event):" << event->type();
if (event->type() == QEvent::Show)
{
if (!m_isVisibale)
{
m_isVisibale = true;
this->setAttribute(Qt::WA_Mapped);
}
qDebug() << "QEvent::LayoutRequest:" << event->type();
}
return QWidget::event(event);
处理showEvent事件
void xxx::showEvent(QShowEvent * event)
{
setAttribute(Qt::WA_Mapped);
QWidget::showEvent(event);
}
Qt下使用QNetworkAccessManager报ssl错误
openssl的问题
qt已经集成了openssl,只要将QCreator中的libeay32.dll 和 ssleay32.dll拷贝到相应的mingw的bin目录下就可以了。
Failed: “SSL handshake failed”
忽略掉错误证书就行了
QNetworkRequest request;
QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(conf);
Qt下窗口变化导致createDIB: CreateDIBSection failed.
将maximumSize设置为一个合适的大小