Qt-interest Archive, May 2008
NO WAY(!!!???) to get a top window with a semi-transparent background
Message 1 in thread
Hi,
I've read so many documents/discussions and tried various methods, however I
can't get a semi-transparent background for the top window. All existing
approaches only work for child widgets or the entire top window including
background and foreground.
So, I doubt that Qt4 doesn't support it, does it?
Message 2 in thread
This is going to be window manager specifc. The issue will come down to
how skins are handled. The window frame and tilebar is sometimes
handled byt the WM and other times by the application...
So you can make the inside of the frame transparent.. however, you cant
make the titlebar/frame..
To get around that, set the window flags to turn off the titlebar and
fram and create your own titlebar/frame as needed...
Scott
From: huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] On Behalf Of FQTerm
Sent: Friday, May 02, 2008 12:32 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: NO WAY(!!!???) to get a top window with a semi-transparent
background
Hi,
I've read so many documents/discussions and tried various methods,
however I can't get a semi-transparent background for the top window.
All existing approaches only work for child widgets or the entire top
window including background and foreground.
So, I doubt that Qt4 doesn't support it, does it?
Message 3 in thread
On Sat, May 3, 2008 at 3:39 AM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
wrote:
> This is going to be window manager specifc. The issue will come down to
> how skins are handled. The window frame and tilebar is sometimes handled
> byt the WM and other times by the application…
>
>
>
> So you can make the inside of the frame transparent.. however, you cant
> make the titlebar/frame..
>
What do you mean by "the inside of the frame"? If you mean the background of
the top window, how to make it semi-transparent?
>
>
> To get around that, set the window flags to turn off the titlebar and fram
> and create your own titlebar/frame as needed…
>
>
>
> Scott
>
> *From:* huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] *On Behalf Of *FQTerm
> *Sent:* Friday, May 02, 2008 12:32 PM
> *To:* qt-interest@xxxxxxxxxxxxx
> *Subject:* NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
> Hi,
> I've read so many documents/discussions and tried various methods, however
> I can't get a semi-transparent background for the top window. All existing
> approaches only work for child widgets or the entire top window including
> background and foreground.
>
> So, I doubt that Qt4 doesn't support it, does it?
>
Message 4 in thread
On Friday 02 May 2008 22:07:35 FQTerm wrote:
> What do you mean by "the inside of the frame"? If you mean the background
> of the top window, how to make it semi-transparent?
thats platform specific.
on X11 you can't do real transparancy becouse there will always be a WM window
in the back. so you have to grab the background and repaint it.
if you're fine with bitmap transparency you can use XShape.
no clue for other OS, but maybe that helps
http://doc.trolltech.com/qq/qq16-background.html
--
[ signature omitted ]
Message 5 in thread
Sorry.. should of gone into more detail...
Essentially, you create a region representing every pixel you want to be
transparent.
If you create and set the region in a resizeEvent method, you can
actually get the size of the outside frame as well...
Here is a simple code snippet for QDial..
#include <QDial>
#include <QApplication>
#include <QResizeEvent>
class CMyDial : public QDial
{
public:
CMyDial( QWidget * parent=NULL ) :
QDial( parent )
{
}
void resizeEvent( QResizeEvent * event )
{
int width = event->size().width();
int height = event->size().height();
qreal r = qMin(width, height) / 2.0;
qreal d_ = r / 6.0;
qreal dx = d_ + (width - 2 * r) / 2.0 + 1;
qreal dy = d_ + (height - 2 * r) / 2.0 + 1;
QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2),
int(r * 2 - 2 * d_ - 2));
QRegion mask( br, QRegion::Ellipse );
setMask( mask );
QDial::resizeEvent( event );
}
};
int main( int argc, char ** argv )
{
QApplication appl( argc, argv );
CMyDial dial;
dial.show();
appl.exec();
}
From: Hua Su [mailto:huas.su@xxxxxxxxx]
Sent: Friday, May 02, 2008 1:06 PM
To: Scott Aron Bloom
Cc: qt-interest@xxxxxxxxxxxxx
Subject: Re: NO WAY(!!!???) to get a top window with a semi-transparent
background
On Sat, May 3, 2008 at 3:39 AM, Scott Aron Bloom
<Scott.Bloom@xxxxxxxxxxxx> wrote:
This is going to be window manager specifc. The issue will come down to
how skins are handled. The window frame and tilebar is sometimes
handled byt the WM and other times by the application...
So you can make the inside of the frame transparent.. however, you cant
make the titlebar/frame..
What do you mean by "the inside of the frame"? If you mean the
background of the top window, how to make it semi-transparent?
To get around that, set the window flags to turn off the
titlebar and fram and create your own titlebar/frame as needed...
Scott
From: huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] On Behalf Of
FQTerm
Sent: Friday, May 02, 2008 12:32 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: NO WAY(!!!???) to get a top window with a
semi-transparent background
Hi,
I've read so many documents/discussions and tried various
methods, however I can't get a semi-transparent background for the top
window. All existing approaches only work for child widgets or the
entire top window including background and foreground.
So, I doubt that Qt4 doesn't support it, does it?
Message 6 in thread
Actually I need a semi-transparent top window, while QWidget::setMask() can
only generate transparent top windows. Thanks all the same.
On Sat, May 3, 2008 at 6:20 AM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
wrote:
> Sorry.. should of gone into more detail…
>
>
>
> Essentially, you create a region representing every pixel you want to be
> transparent.
>
>
>
> If you create and set the region in a resizeEvent method, you can actually
> get the size of the outside frame as well…
>
>
>
> Here is a simple code snippet for QDial..
>
>
>
> #include <QDial>
>
> #include <QApplication>
>
> #include <QResizeEvent>
>
>
>
> class CMyDial : public QDial
>
> {
>
> public:
>
> CMyDial( QWidget * parent=NULL ) :
>
> QDial( parent )
>
> {
>
> }
>
>
>
> void resizeEvent( QResizeEvent * event )
>
> {
>
> int width = event->size().width();
>
> int height = event->size().height();
>
> qreal r = qMin(width, height) / 2.0;
>
> qreal d_ = r / 6.0;
>
> qreal dx = d_ + (width - 2 * r) / 2.0 + 1;
>
> qreal dy = d_ + (height - 2 * r) / 2.0 + 1;
>
> QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2),
> int(r * 2 - 2 * d_ - 2));
>
>
>
> QRegion mask( br, QRegion::Ellipse );
>
> setMask( mask );
>
> QDial::resizeEvent( event );
>
> }
>
> };
>
>
>
>
>
> int main( int argc, char ** argv )
>
> {
>
> QApplication appl( argc, argv );
>
> CMyDial dial;
>
> dial.show();
>
> appl.exec();
>
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
> *From:* Hua Su [mailto:huas.su@xxxxxxxxx]
> *Sent:* Friday, May 02, 2008 1:06 PM
> *To:* Scott Aron Bloom
> *Cc:* qt-interest@xxxxxxxxxxxxx
> *Subject:* Re: NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
>
>
> On Sat, May 3, 2008 at 3:39 AM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
> wrote:
>
> This is going to be window manager specifc. The issue will come down to
> how skins are handled. The window frame and tilebar is sometimes handled
> byt the WM and other times by the application…
>
>
>
> So you can make the inside of the frame transparent.. however, you cant
> make the titlebar/frame..
>
> What do you mean by "the inside of the frame"? If you mean the background
> of the top window, how to make it semi-transparent?
>
>
>
> To get around that, set the window flags to turn off the titlebar and fram
> and create your own titlebar/frame as needed…
>
>
>
> Scott
>
> *From:* huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] *On Behalf Of *FQTerm
> *Sent:* Friday, May 02, 2008 12:32 PM
> *To:* qt-interest@xxxxxxxxxxxxx
> *Subject:* NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
> Hi,
> I've read so many documents/discussions and tried various methods, however
> I can't get a semi-transparent background for the top window. All existing
> approaches only work for child widgets or the entire top window including
> background and foreground.
>
> So, I doubt that Qt4 doesn't support it, does it?
>
>
>
Message 7 in thread
Did you try using the setMask( QBitmap) or the setWindowOpacity()
methods?
setWindowOpacity works very well.. however, its everything, the
forground and background of the image...
Scott
From: huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] On Behalf Of FQTerm
Sent: Friday, May 02, 2008 9:07 PM
To: Scott Aron Bloom
Cc: qt-interest@xxxxxxxxxxxxx
Subject: Re: NO WAY(!!!???) to get a top window with a semi-transparent
background
Actually I need a semi-transparent top window, while QWidget::setMask()
can only generate transparent top windows. Thanks all the same.
On Sat, May 3, 2008 at 6:20 AM, Scott Aron Bloom
<Scott.Bloom@xxxxxxxxxxxx> wrote:
Sorry.. should of gone into more detail...
Essentially, you create a region representing every pixel you want to be
transparent.
If you create and set the region in a resizeEvent method, you can
actually get the size of the outside frame as well...
Here is a simple code snippet for QDial..
#include <QDial>
#include <QApplication>
#include <QResizeEvent>
class CMyDial : public QDial
{
public:
CMyDial( QWidget * parent=NULL ) :
QDial( parent )
{
}
void resizeEvent( QResizeEvent * event )
{
int width = event->size().width();
int height = event->size().height();
qreal r = qMin(width, height) / 2.0;
qreal d_ = r / 6.0;
qreal dx = d_ + (width - 2 * r) / 2.0 + 1;
qreal dy = d_ + (height - 2 * r) / 2.0 + 1;
QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2),
int(r * 2 - 2 * d_ - 2));
QRegion mask( br, QRegion::Ellipse );
setMask( mask );
QDial::resizeEvent( event );
}
};
int main( int argc, char ** argv )
{
QApplication appl( argc, argv );
CMyDial dial;
dial.show();
appl.exec();
}
From: Hua Su [mailto:huas.su@xxxxxxxxx]
Sent: Friday, May 02, 2008 1:06 PM
To: Scott Aron Bloom
Cc: qt-interest@xxxxxxxxxxxxx
Subject: Re: NO WAY(!!!???) to get a top window with a semi-transparent
background
On Sat, May 3, 2008 at 3:39 AM, Scott Aron Bloom
<Scott.Bloom@xxxxxxxxxxxx> wrote:
This is going to be window manager specifc. The issue will come down to
how skins are handled. The window frame and tilebar is sometimes
handled byt the WM and other times by the application...
So you can make the inside of the frame transparent.. however, you cant
make the titlebar/frame..
What do you mean by "the inside of the frame"? If you mean the
background of the top window, how to make it semi-transparent?
To get around that, set the window flags to turn off the
titlebar and fram and create your own titlebar/frame as needed...
Scott
From: huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] On Behalf Of
FQTerm
Sent: Friday, May 02, 2008 12:32 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: NO WAY(!!!???) to get a top window with a
semi-transparent background
Hi,
I've read so many documents/discussions and tried various
methods, however I can't get a semi-transparent background for the top
window. All existing approaches only work for child widgets or the
entire top window including background and foreground.
So, I doubt that Qt4 doesn't support it, does it?
Message 8 in thread
On Sat, May 3, 2008 at 12:31 PM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
wrote:
> Did you try using the setMask( QBitmap) or the setWindowOpacity()
> methods?
>
> setWindowOpacity works very well.. however, its everything, the forground
> and background of the image…
>
I tried both and neither is what I want. setMask() can only generate
transparent top windows, not semi-transparent ones. setWindowOpacity() can
make the entire window semi-transparent, while what I want is
semi-transparent background only.
>
>
> Scott
>
>
>
> *From:* huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] *On Behalf Of *FQTerm
> *Sent:* Friday, May 02, 2008 9:07 PM
>
> *To:* Scott Aron Bloom
> *Cc:* qt-interest@xxxxxxxxxxxxx
> *Subject:* Re: NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
> Actually I need a semi-transparent top window, while QWidget::setMask() can
> only generate transparent top windows. Thanks all the same.
>
> On Sat, May 3, 2008 at 6:20 AM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
> wrote:
>
> Sorry.. should of gone into more detail…
>
>
>
> Essentially, you create a region representing every pixel you want to be
> transparent.
>
>
>
> If you create and set the region in a resizeEvent method, you can actually
> get the size of the outside frame as well…
>
>
>
> Here is a simple code snippet for QDial..
>
>
>
> #include <QDial>
>
> #include <QApplication>
>
> #include <QResizeEvent>
>
>
>
> class CMyDial : public QDial
>
> {
>
> public:
>
> CMyDial( QWidget * parent=NULL ) :
>
> QDial( parent )
>
> {
>
> }
>
>
>
> void resizeEvent( QResizeEvent * event )
>
> {
>
> int width = event->size().width();
>
> int height = event->size().height();
>
> qreal r = qMin(width, height) / 2.0;
>
> qreal d_ = r / 6.0;
>
> qreal dx = d_ + (width - 2 * r) / 2.0 + 1;
>
> qreal dy = d_ + (height - 2 * r) / 2.0 + 1;
>
> QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2),
> int(r * 2 - 2 * d_ - 2));
>
>
>
> QRegion mask( br, QRegion::Ellipse );
>
> setMask( mask );
>
> QDial::resizeEvent( event );
>
> }
>
> };
>
>
>
>
>
> int main( int argc, char ** argv )
>
> {
>
> QApplication appl( argc, argv );
>
> CMyDial dial;
>
> dial.show();
>
> appl.exec();
>
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
> *From:* Hua Su [mailto:huas.su@xxxxxxxxx]
> *Sent:* Friday, May 02, 2008 1:06 PM
> *To:* Scott Aron Bloom
> *Cc:* qt-interest@xxxxxxxxxxxxx
> *Subject:* Re: NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
>
>
> On Sat, May 3, 2008 at 3:39 AM, Scott Aron Bloom <Scott.Bloom@xxxxxxxxxxxx>
> wrote:
>
> This is going to be window manager specifc. The issue will come down to
> how skins are handled. The window frame and tilebar is sometimes handled
> byt the WM and other times by the application…
>
>
>
> So you can make the inside of the frame transparent.. however, you cant
> make the titlebar/frame..
>
> What do you mean by "the inside of the frame"? If you mean the background
> of the top window, how to make it semi-transparent?
>
>
>
> To get around that, set the window flags to turn off the titlebar and fram
> and create your own titlebar/frame as needed…
>
>
>
> Scott
>
> *From:* huas.su@xxxxxxxxx [mailto:huas.su@xxxxxxxxx] *On Behalf Of *FQTerm
> *Sent:* Friday, May 02, 2008 12:32 PM
> *To:* qt-interest@xxxxxxxxxxxxx
> *Subject:* NO WAY(!!!???) to get a top window with a semi-transparent
> background
>
>
>
> Hi,
> I've read so many documents/discussions and tried various methods, however
> I can't get a semi-transparent background for the top window. All existing
> approaches only work for child widgets or the entire top window including
> background and foreground.
>
> So, I doubt that Qt4 doesn't support it, does it?
>
>
>
>
>
Message 9 in thread
FQTerm wrote:
> Hi,
> I've read so many documents/discussions and tried various methods,
> however I can't get a semi-transparent background for the top window.
> All existing approaches only work for child widgets or the entire top
> window including background and foreground.
>
> So, I doubt that Qt4 doesn't support it, does it?
>
I know it's a bit of a hack, but I've done something similar with .NET
by creating two top level windows, one for the semi-transparent
background, one for the non-transparent controls, and syncing up their
movement. There probably is some more elegant solution out there.
--
[ signature omitted ]