Apply background image to a Qmenu

1.2k views Asked by At

I need to apply an background image to a Qmenu. So far I only can put a color as a background. It seems the property background or background-image isn't work (using qss stylesheet). I've tried applying styles within the code. The same results. Any suggestions? Just in case, I'm using Qt Creator 2.0.1 with QT 4.7 in mac OSx.

Thanks in advance.

1

There are 1 answers

0
serge_gubenko On

I guess you should post up some of your code; looks like the problem is in the way how you define your style sheet(s).

Setting background images via stylesheet works fine for QMenu and QMenyBar widgets. Check if an example below would work for you:

// sets background to QMenuBar and QMeny
menuBar->setStyleSheet("QMenuBar {background-image: url(/home/menubar_image.jpg)} QMenu {background-image: url(/home/menu_image.jpg)}");
// sets background to QMenu
menu->setStyleSheet("QMenu {background-image: url(/home/menu_image.jpg)}");

hope this helps, regards