Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

QT使用的时候如果把窗口隐藏再显示出来内容都不见了 #86

Open
icew4y opened this issue Mar 7, 2021 · 0 comments
Open

Comments

@icew4y
Copy link

icew4y commented Mar 7, 2021

我是在QDialog里面嵌入的QCefView,因为关闭QDialog的时候,父窗口会阻塞卡死。
我用隐藏窗口的办法也出问题了,我在窗口重新显示的时候尝试调用navigateToUrl,直接崩溃报错
cef_ref_counted.h(325)] Assert failed: ptr_ != 0.

CaptchaDialog::CaptchaDialog(QWidget parent) :
QDialog(parent),
ui(new Ui::CaptchaDialog)
{
qDebug() << "CaptchaDialog init";
ui->setupUi(this);
QHBoxLayout
layout = new QHBoxLayout();
layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(3);
QDir dir = QCoreApplication::applicationDirPath();
QCefSetting::setBrowserSubProcessPath(dir.filePath("QCefWing.exe"));
QCefSetting::setResourceDirectoryPath(dir.filePath("resources"));
QCefSetting::setLocalesDirectoryPath(dir.filePath("resources/locales"));
cefview = new CustomCefView("https://www.google.com", ui->Container);
ui->vl_container->addWidget(cefview);
}

CaptchaDialog::~CaptchaDialog()
{
delete ui;
}

void CaptchaDialog::closeEvent(QCloseEvent *event)
{
qDebug() << "CaptchaDialog closeEvent";
showMinimized();
}

void CaptchaDialog::showEvent(QShowEvent *event)
{
qDebug() << "CaptchaDialog showEvent";
cefview->navigateToUrl(QString("http://www.qq.com/"));
}

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant