Important: Please read the Qt Code of Conduct -

QGraphicsSvgItem is not recognizing the files with the svg images

  • Hi,
    here is the class that i'm having problems with

    DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
                 QGraphicsItem *parent)
        : QGraphicsSvgItem(parent)
        myDiagramType = diagramType;
        myContextMenu = contextMenu;
        switch (myDiagramType) {
            case StartEnd:{
                item = new QSvgRenderer(QLatin1String("C:/Users/Lukas/Desktop/simulight_v2/images/trafosvg"));
                //this is the path for the svg image that i want to use
        case Gerador:{
                item = new QSvgRenderer(QLatin1String("C:/Users/Lukas/Desktop/simulight_v2/images/geradorsvg"));
    }// here the switch ends
        setFlag(QGraphicsItem::ItemIsMovable, true);
        setFlag(QGraphicsItem::ItemIsSelectable, true);
        setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    the problem is that qt says it cannot open these files because they were not found, how can i fix it?

  • Lifetime Qt Champion


    Aren't you missing the file extension ?
    Or a dot before the svg at the end of the filename ?

Log in to reply