Project

General

Profile

Can't set alpha-level of WContainerWidget

Added by Harm ​ about 4 years ago

Hello,

 

 

I'm trying to make the background color of a WContainerWidget transparent, by using

container->decorationStyle().setBackgroundColor(Wt::WColor(255, 0, 0, 128));

I'm expecting a semi-transparent red container, but instead I'm getting a fully opaque red container.

Firefox' inspector shows that there's indeed no alpha-value in the rgb()-property:

<div id="o3knw4h" style="background-color:rgb(255,0,0);"></div>

I'm using Wt v3.5.0.

 

 

How can I make my WContainerWidget transparent?

 

 

Regards,

Harm.


Replies (2)

RE: Can't set alpha-level of WContainerWidget - Added by Roel Standaert about 4 years ago

Hi,

Sorry that I didn't respond immediately. I looked into it, and currently Wt does indeed only support opaque background colors through that API. That may be because not every browser supported rgba back then. If you make a feature request, I can look into making that possible.

So, the only way to do it right now would be through CSS, e.g. defining it in a CSS class and then adding that class through addStyleClass.

Regards,

Roel

RE: Can't set alpha-level of WContainerWidget - Added by Harm ​ about 4 years ago

Hi Roel,

 

 

Roel Standaert wrote:

Sorry that I didn't respond immediately.

No problem.

 

 

Roel Standaert wrote:

I looked into it, and currently Wt does indeed only support opaque background colors through that API.

Ah, so it wasn't just me. I looked around on the forum and saw that no one else had this problem, I thought I was missing something.

 

 

Roel Standaert wrote:

If you make a feature request, I can look into making that possible.

Done, see #7434.

 

 

Roel Standaert wrote:

So, the only way to do it right now would be through CSS, e.g. defining it in a CSS class and then adding that class through addStyleClass.

Sure, that's how I ended up doing it.

 

 

Thanks!

    (1-2/2)