Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Apply background-image to a Qmenu
Forum Updated to NodeBB v4.3 + New Features

Apply background-image to a Qmenu

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kernellstudios
    wrote on last edited by
    #1

    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.
    David.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      prajnaranjan.das
      wrote on last edited by
      #2

      Try this

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

      Prajnaranjan Das

      e mail: prajnaranjan.das@gmail.com

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kernellstudios
        wrote on last edited by
        #3

        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
        @
        Qmenu{
        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); }"
        @

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sven.bergner
          wrote on last edited by
          #4

          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.

          Coding less and creating more with every new version of Qt a bit more.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved