Important: Please read the Qt Code of Conduct -

Apply background-image to a Qmenu

  • Hi everyone,

    I was trying to apply an image background to a Qmenu. So far, I only can put a color background. Im using Qt 4.7.1 for Mac OSX and QT Creator 2.0.1. Suggestions?

    Thanks in advance.

  • Try this

    setStyleSheet("QMenu#objectname {background-image: url(:/images/folder name/ image format);}");

  • Hi, thanks for your answer!
    I tried that way too, and its not kicking. I tried using qss and setting styles within code:

    qss stylesheet
    background-image: url(':/some_pic.png');
    border: solid 1px #FFF;

    within code:
    QMenu *menu = new QMenu;
    menu->addAction('Item 1');
    menu->setStyleSheet("QMenu#menu{ background-image: url(:/some_pic.png); }"
    //also tried menu->setStyleSheet("QMenu{ background-image: url(:/some_pic.png); }"

  • Do you have the image you want to show in your resources? If I remember correctly refers :/ to you resources. You can try url("some_pic.png") to load a image from disk.

Log in to reply