本文整理汇总了C++中QWebPage::palette方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebPage::palette方法的具体用法?C++ QWebPage::palette怎么用?C++ QWebPage::palette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebPage
的用法示例。
在下文中一共展示了QWebPage::palette方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: palette
QPalette QWebPageProto::palette() const
{
QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
if (item)
return item->palette();
return QPalette();
}
示例2: main
int main(int argc, char *argv[])
{
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
action.sa_handler = term;
sigaction(SIGTERM, &action, NULL);
int fps = atoi(argv[4]);
int width = atoi(argv[2]);
int height = atoi(argv[3]);
init_shared_data(atoi(argv[2]), atoi(argv[3]));
QApplication app(argc, argv);
QWebPage page;
QPalette palette = page.palette();
palette.setBrush(QPalette::Base, Qt::transparent);
page.setPalette(palette);
page.mainFrame()->setUrl(QUrl::fromUserInput(argv[1]));
page.setViewportSize(QSize(width, height));
page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
pthread_mutex_lock(&data->mutex);
QImage image(&data->data, width, height, QImage::Format_RGBA8888);
QPainter painter(&image);
pthread_mutex_unlock(&data->mutex);
while (!done) {
app.processEvents();
pthread_mutex_lock(&data->mutex);
image.fill(0);
page.mainFrame()->render(&painter, QWebFrame::ContentsLayer);
pthread_mutex_unlock(&data->mutex);
usleep(1000000 / fps);
}
return 0;
}
示例3: paint
void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );
if ( !painter )
{
return;
}
if ( !shouldDrawItem() )
{
return;
}
drawBackground( painter );
painter->save();
//antialiasing on
painter->setRenderHint( QPainter::Antialiasing, true );
double penWidth = hasFrame() ? pen().widthF() : 0;
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, rect().width() - 2 * penWidth - 2 * mMargin, rect().height() - 2 * penWidth - 2 * mMargin );
QString textToDraw = displayText();
if ( mHtmlState )
{
painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 );
QWebPage *webPage = new QWebPage();
webPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
//Setup event loop and timeout for rendering html
QEventLoop loop;
QTimer timeoutTimer;
timeoutTimer.setSingleShot( true );
//This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
QPalette palette = webPage->palette();
palette.setBrush( QPalette::Base, Qt::transparent );
webPage->setPalette( palette );
//webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ?
webPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) );
webPage->mainFrame()->setZoomFactor( 10.0 );
webPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
webPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
// QGIS segfaults when rendering web page while in composer if html
// contains images. So if we are not printing the composition, then
// disable image loading
if ( mComposition->plotStyle() != QgsComposition::Print &&
mComposition->plotStyle() != QgsComposition::Postscript )
{
webPage->settings()->setAttribute( QWebSettings::AutoLoadImages, false );
}
//Connect timeout and webpage loadFinished signals to loop
connect( &timeoutTimer, SIGNAL( timeout() ), &loop, SLOT( quit() ) );
connect( webPage, SIGNAL( loadFinished( bool ) ), &loop, SLOT( quit() ) );
//mHtmlLoaded tracks whether the QWebPage has completed loading
//its html contents, set it initially to false. The loadingHtmlFinished slot will
//set this to true after html is loaded.
mHtmlLoaded = false;
connect( webPage, SIGNAL( loadFinished( bool ) ), SLOT( loadingHtmlFinished( bool ) ) );
webPage->mainFrame()->setHtml( textToDraw );
//For very basic html labels with no external assets, the html load will already be
//complete before we even get a chance to start the QEventLoop. Make sure we check
//this before starting the loop
if ( !mHtmlLoaded )
{
// Start a 20 second timeout in case html loading will never complete
timeoutTimer.start( 20000 );
// Pause until html is loaded
loop.exec();
}
webPage->mainFrame()->render( painter );//DELETE WEBPAGE ?
}
else
{