Qt下遇到的一些奇怪问题

Windows

warning::setGeometry: Unable to set geometry

  1. 设置窗口标记位 setWindowFlags (Qt::MSWindowsFixedSizeDialogHint);
  2. 设置它的最大大小和最小大小
//最小值
setMinimumSize(500, 500);
//最大值
setMaximumSize(500, 500);
  1. 使用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.dllssleay32.dll拷贝到相应的mingwbin目录下就可以了。

Failed: “SSL handshake failed”

忽略掉错误证书就行了

QNetworkRequest request;

QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(conf);

Qt下窗口变化导致createDIB: CreateDIBSection failed.

maximumSize设置为一个合适的大小

Linux

Mac OS

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,针对这个问题,我可以给您提供一些关于Qt在Linux下环境问题的解决方案: 1. 缺少依赖库:在安装Qt之前,需要先安装一些必要的依赖库,如libgl1-mesa-dev、libfontconfig1-dev、libdbus-1-dev等。如果在编译或运行过程中出现缺失依赖库的错误,可以通过sudo apt-get命令安装相应的库文件。 2. 编译错误:在编译Qt项目时,可能会出现各种各样的错误,例如“error: ‘nullptr’ was not declared in this scope”、“error: cannot convert ‘const char*’ to ‘QString’ in initialization”等。这些错误通常是由于版本不兼容或者缺少头文件等问题引起的。解决方法是检查版本是否匹配,确认头文件是否存在等。 3. 字体问题:在Qt中,字体是非常重要的元素。如果系统中的字体不兼容或者缺失,可能会导致Qt应用程序显示不正常。解决方法是在系统中安装所需的字体,或者在Qt应用程序中指定使用的字体。 4. 环境变量问题:在Linux系统中,Qt需要设置一些环境变量才能正常运行。例如,QTDIR、QT_PLUGIN_PATH、LD_LIBRARY_PATH等。如果这些环境变量设置不正确或者缺失,可能会导致Qt应用程序无法启动。解决方法是正确设置这些环境变量。 5. 调试问题:在开发Qt应用程序时,可能会出现各种各样的调试问题,例如程序崩溃、死锁等。解决方法是使用调试工具,如gdb,进行调试,并分析日志信息。 这些是我能够为您提供的一些解决方案,希望对您有所帮助。如果您有其他问题,请随时提出。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄权浩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值