Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QIcon problem



  • I have a problem when declaring QIcon, I want to add images to a QlistWidget and enter this QListWidgetItem item= new QListWidgetItem(QIcon(":/img/imagenes/img/waffles.png"),"Desayunos"); but I get this error error: no viable conversion from 'QListWidgetItem *' to 'QListWidgetItem'
    I also get an error that says QIcon not initialized
    I do not know if I am missing a library or any statement, please I hope they help me: c



  • @Ileana said in QIcon problem:

    QListWidgetItem item= new QListWidgetItem(QIcon(":/img/imagenes/img/waffles.png"),"Desayunos");

    Variable should be pointer to item as it's allocated on heap using new.
    QListWidgetItem *item = new QListWidgetItem(QIcon(":/img/imagenes/img/waffles.png"),"Desayunos");



  • @nagesh Thank you :3 it has helped me.


Log in to reply