我扩展了QWebEngineView
。
#ifndef MYQWEBENGINEVIEW_H
#define MYQWEBENGINEVIEW_H
#include <QWebEngineView>
class MyQWebEngineView : public QWebEngineView
{
public:
MyQWebEngineView(QWidget *parent = 0);
~MyQWebEngineView();
protected:
virtual void paintEvent(QPaintEvent *);
};
#endif // MYQWEBENGINEVIEW_H
但我不能被叫到paintEvent(QPaintEvent *)
。
#include "myqwebengineview.h"
#include <QPaintEvent>
#include <QPainter>
#include <QWebEngineView>
#include <QWidget>
MyQWebEngineView::MyQWebEngineView(QWidget *parent):QWebEngineView(parent)
{
qDebug() << "MyQWebEngineView(" << parent << ")";
qDebug() << "Qt::WA_PaintOnScreen: " << testAttribute(Qt::WA_PaintOnScreen);
//setAttribute(Qt::WA_PaintOnScreen, true);
}
MyQWebEngineView::~MyQWebEngineView()
{
}
void MyQWebEngineView::paintEvent(QPaintEvent * event)
{
qDebug() << "paintEvent(" << event << ")";
QWebEngineView::paintEvent(event);
//QWidget::paintEvent(event);
qDebug() << event->rect();
qDebug() << event->region();
}
谁能告诉我怎么了?