Qt:如何在运行时更改svg图像

时间:2016-04-01 07:34:43

标签: c++ windows image qt svg

我有一个CloseItem的自定义类,即QGraphicsItemGroup。我的自定义类的对象已添加到class CloseItem : public QObject, public QGraphicsSvgItem{ protected: QSvgRenderer *close; QSvgRenderer *closeHover; public: CloseItem (QGraphicsItem * parent = 0) : QObject(), QGraphicsSvgItem(parent){ close = new QSvgRenderer(QStringLiteral("img/x icon 16x16.svg")); closeHover = new QSvgRenderer(QStringLiteral("img/x icon hover 16x16.svg")); this->setSharedRenderer(close); this->setElementId("close"); } void hoverEnterEvent(QGraphicsSceneHoverEvent *e) override{ this->setSharedRenderer(closeHover); } void hoverLeaveEvent(QGraphicsSceneHoverEvent *e) override{ this->setSharedRenderer(close); } };

现在我的自定义类svg项目的悬停事件,我想更改svg图像。

代码

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {  
 auth
 .authenticationProvider(activeDirectoryLdapAuthenticationProvider());
}

@Bean
public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {

    ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(domain,
            server, dn);
    CustomLdapUserDetailsMapper ldapUserDetailsMapper = new CustomLdapUserDetailsMapper();
    ldapUserDetailsMapper.setConvertToUpperCase(true);
    provider.setUserDetailsContextMapper(ldapUserDetailsMapper);
    return provider;
}

问题:在这里,我没有获得svg图片。

0 个答案:

没有答案