Sunday, July 20th 2008, 2:16am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, May 8th 2008, 7:42am

stylesheet for menuitem

hi,
i'm change interface of my project, but got some issue.
one of them just is stylesheet for menuitem.
i intend to change my interface with below this picture.
i tried many ways to do it and i have been done it with proper way, but others issue occured.
so i tried to use stylesheet.
the code says
QMenu {
background: rgb(255, 255, 255);
}

QMenu::item {
padding: 2px 25px 2px 25px;
border: 1px solid transparent;
}

QMenu::item:selected:enabled {
border-color: rgb(255, 189, 105);
background: rgba(255, 231, 162, 150);
}

QMenu::separator {
height: 2px;
background: rgb(173, 209, 255);
margin-left: 25px;
}

QMenu::indicator {
width: 13px;
height: 13px;
}
i don't know how to change first code (background: rgb(255, 255, 255);) to make my completion interface.
can anybody help me?
thanks
sgh has attached the following file:
  • 1.jpg (12.82 kB - 155 times downloaded - Last download: Jul 11th 2008, 1:45pm)

This post has been edited 2 times, last edit by "sgh" (May 8th 2008, 7:45am)

  • Go to the top of the page

2

Thursday, May 8th 2008, 8:30pm

You can try
background-color:qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #147CB4, stop: .2 #ffffff stop: 1 #ffffff);

you can play around with the colors and stops to get it right.
  • Go to the top of the page

3

Friday, May 9th 2008, 2:00am

Quoted

Originally posted by s_p_t10
You can try
background-color:qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #147CB4, stop: .2 #ffffff stop: 1 #ffffff);

you can play around with the colors and stops to get it right.


hi,s_p_t10
i tried already for a long days ago.
when i did with your help, the problem occur.
my menuitem size(width) is changeable. that is sizes are all different.
but the area of displaying in menuitem(bright green color, part of icon) is static.
can you give me any idea?
thanks for reply
  • Go to the top of the page

4

Friday, May 9th 2008, 6:38pm

try avoiding padding and border on QMenu::item
Nicolas
  • Go to the top of the page

5

Saturday, May 10th 2008, 5:03am

Quoted

Originally posted by Nicolas SOUCHON
try avoiding padding and border on QMenu::item

i dont understand "try avoiding padding and border on QMenu::item".
you mean QMenu::item delete?
i tried to do this, but result is not fine.
and to be more precise, color is showed item not to have icon.
the picture is like below
well, can you write code exactly or suggest any idea?
sgh has attached the following file:
  • 1.jpg (20.6 kB - 79 times downloaded - Last download: Jul 11th 2008, 1:46pm)

This post has been edited 1 times, last edit by "sgh" (May 10th 2008, 5:05am)

  • Go to the top of the page

6

Monday, May 12th 2008, 8:08pm

For variable menu item lengths, here is what works for me:

QMenu {
background-color:white;
background-image: url(../qss/menuBack.png) ;
background-repeat: repeat-y;
}

QMenu::item {
padding: 2px 25px 2px 25px;
border: 1px solid transparent;
}

QMenu::item:selected:enabled {
border-color: rgb(250, 170, 60);
background: rgba(250, 170, 60, 50);
}

QMenu::separator {
height: 2px;
background: rgb(168, 216, 235);
margin-left: 25px;
}

QMenu::indicator {
width: 13px;
height: 13px;
}
where menuBack.png is attached
s_p_t10 has attached the following image:
  • menuBack.png
  • Go to the top of the page

7

Tuesday, May 13th 2008, 1:25am

hi,s_p_t10
thanks for reply.
and this is one of good ways, but i tried to do already.
then i found some problem while using image in qss happen when i did open with.
in other words, i open properly files by open with when clicking right button, my app doesnt do reference image(menuBack.png).
i dont knwo why it happen.
so i did mind to use way out of using image, but i have issue here.
can you tell me other idea?
  • Go to the top of the page

8

Tuesday, May 13th 2008, 6:19pm

Are you trying to say that if you use right click 'open with' to start your app, then the image is not found, so you want to have a solution without using images?

In that case, you should create a qrc from all your resources and embedd the qrc into your app. That way you can use :/ to refer to the image path. See http://doc.trolltech.com/4.4/resources.html for more details on qrc.

Sharmila.
  • Go to the top of the page

9

Thursday, May 15th 2008, 1:51am

thanks for reply.
and my working is fine by your help.
i saw documents for it for a few days ago, but i missed one problem so i had some wrong, but now is fine.
thanks again.
  • Go to the top of the page

Rate this thread