July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

Qss in widget

 

Hellow!
I have widget and widget set color, for example red, and when this widget include in other widget, for example window, there is no color, but if widget is separate window that all right
I use following qss code

  1.   RSeveralElements
  2. {
  3.   border: 1 solid rgb(136, 136, 136);
  4.   border-radius: 6px;
  5.   min-height: 20px;
  6.   min-width: 40px;
  7.   background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  8.                                  stop: 0 #cccccc, stop: 1 #eeeeee);
  9. }

RSeveralElements heir of QWidget
Advance many thanks for your help!

12 replies

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

Have a look at this thread. [developer.qt.nokia.com]

I think your situation is similar.

In what widget to you include RSeveralElements?

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

I include it in main layout(QVBoxLayout) in QMainWindow

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

Many thanks for your help, it is work!

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

I’m glad for you.

Please add [Solved] in front of your title

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

I was a little hasty with the findings, it work, but it work wrong
This is full qss code after fixed

  1.   RSeveralElements, RSeveralElements *
  2. {
  3.   border: 1 solid rgb(136, 136, 136);
  4.   border-radius: 6px;
  5.   min-height: 20px;
  6.   min-width: 40px;
  7.   background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  8.                                  stop: 0 #cccccc, stop: 1 #eeeeee);
  9. }
  10.   RSeveralWidget, RSeveralWidget *{
  11.   background-color: transparent;
  12. }
  13. RSeveralWidget:hover, RSeveralWidget *:hover{
  14.   border: 1 solid #55aaff;
  15. }

RSeveralElements(parent: QWidget) is widget-panel, where situate QSeveralWidget(parent: QToolButton)
After that create border in RSeveralWidget, but if i remove this
  1. RSeveralWidget:hover, RSeveralWidget *:hover{
  2.   border: 1 solid #55aaff;
  3. }

There are no to create
But i need to create border in RSeveralElements

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

if I understand you well, your initial problem is solved.

Additionally you want a border when hovering over RSeveralWidget. The qss works here. ( it works in my case, I get a blue border when I hover it.)
But for RSeveralElements you don’t get a border when you hover over it? I don’t see the hover part for that one in your example.

You could add RSeveralElements:hover too.

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

I wish that would border RSeveralElements cover all elements onto RSeveralWidgets
http://hostingkartinok.com/show-image.php?id=29b3ce1c5f18b9ce6fd0329626aad3a8

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

I see, one picture tells more than 1000 words ;)

You can put RSeveralWidgets in a QFrame and let that one highlight.

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

Many thanks, it is work as could!
Tell me, please, why is this happening?

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

I don’t understand what you are saying.

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

Ruzik Ruzik
Lab Rat
293 posts

Sorry for my bad english
I want to ask: Why is the variant with QWidget dont work, and why is it work with QFrame?

July 25, 2011

Eddy Eddy
Gene Splicer
1296 posts

Because you want 2 widgets highlight as one.

Normally 2widgets will highlight as 2 different rectangles.

If you want 1 highlighted rectangle you have to use 1widget. Putting the widgets in a QFrame does the trick.

I hope you understand it now.

 Signature 

Qt Certified Specialist
Qt Ambassador

 
  ‹‹ QtXml dll compiled on VC2010 with /MT and /MTd causes memory access violation running sample .      Debug Error ››

You must log in to post a reply. Not a member yet? Register here!