简体   繁体   English

如何在Internet Explorer COM对象中应用CSS?

[英]How to apply css in internet explorer COM object?

I write in Qt but it shouldn't matter since I only want to use COM funcs This is how I load the IE. 我用Qt编写,但这没关系,因为我只想使用COM函数。这就是我加载IE的方式。

QAxWidget* axieBrowser= new QAxWidget(ui->centralWidget);
axieBrowser->setControl(QString::fromUtf8("{8856F961-340A-11D0-A96B-00C04FD705A2}"));
axieBrowser->dynamicCall("Navigate(const QString&)", "www.google.com");

And now I want to apply css to all pages that I open from this widget. 现在,我想将CSS应用于从此小部件打开的所有页面。 For example: 例如:

body {
    margin:0;
    overflow:hidden;
    opacity: 0.4;
}

In Qt if I use Qt Webkit, I can achieve this using 在Qt中,如果我使用Qt Webkit,则可以使用

ui->webView->page()->settings()->setUserStyleSheetUrl(myCss);

How can I do this using IE COM? 如何使用IE COM执行此操作?

in Qt I managed with the following codes 在Qt中,我使用以下代码进行管理

IDispatch* val = axieBrowser->property("Document").value<IDispatch*>();
QAxObject * obj = new QAxObject((IUnknown*)val);
if (obj)
{
    QAxObject * result = obj->querySubObject("createStyleSheet(QString, int)", "", 0);
    result->setProperty("cssText", "body {  margin:0;   overflow:hidden;    opacity: 0.4;}");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM