Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, June 2007
Transparent background


Message 1 in thread

Hello!

How can I mWindow show with transparent background?

I try: mWindow->setAttribute( Qt::WA_NoSystemBackground );
and
QPalette p = mWindow->palette();
p.setBrush(QPalette::Window, Qt::transparent);
mWindow->setPalette(p);

but nothing happend.

Thanks in advance!

#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QListWidget* mWindow = new QListWidget( 0 );

    mWindow->setGeometry( 0, 530, 1000, 175 );

    QListWidgetItem* wi1 = new QListWidgetItem( QApplication::tr(
"Orders" ), mWindow );

    mWindow->addItem( wi1 );

    mWindow->show();

}

--
 [ signature omitted ] 

Message 2 in thread

On 6/10/07, Dudás József <dj1999@xxxxxxxxxxx> wrote:
> Hello!
>
> How can I mWindow show with transparent background?
>
> I try: mWindow->setAttribute( Qt::WA_NoSystemBackground );
> and
> QPalette p = mWindow->palette();
> p.setBrush(QPalette::Window, Qt::transparent);
> mWindow->setPalette(p);

Try the window opacity property:
http://doc.trolltech.com/4.3/qwidget.html#windowOpacity-prop

-- 
 [ signature omitted ] 

Message 3 in thread

Thanks!

I made it before too:

mWindow->setWindowOpacity( 0.5 );

but didn't help.
> On 6/10/07, Dudás József <dj1999@xxxxxxxxxxx> wrote:
>> Hello!
>>
>> How can I mWindow show with transparent background?
>>
>> I try: mWindow->setAttribute( Qt::WA_NoSystemBackground );
>> and
>> QPalette p = mWindow->palette();
>> p.setBrush(QPalette::Window, Qt::transparent);
>> mWindow->setPalette(p);
>
> Try the window opacity property:
> http://doc.trolltech.com/4.3/qwidget.html#windowOpacity-prop
>

--
 [ signature omitted ] 

Message 4 in thread

The picture is result with mWindow->setWindowOpacity( 0.0 ).

I use Kubuntu edgy with kde 3.5.6. In kde application possible to 
setting transparecy. I was download this: 
http://www.linuxlots.com/~siraj/qtclock.html application and compiled. 
This did not was transparent background than black square on my desktop. 
I used qt 4.2.3 and qt 4.3.0rc1 with same result.

Did Somebody resolve similar challenge?

> Thanks!
>
> I made it before too:
>
> mWindow->setWindowOpacity( 0.5 );
>
> but didn't help.
>> On 6/10/07, Dudás József <dj1999@xxxxxxxxxxx> wrote:
>>> Hello!
>>>
>>> How can I mWindow show with transparent background?
>>>
>>> I try: mWindow->setAttribute( Qt::WA_NoSystemBackground );
>>> and
>>> QPalette p = mWindow->palette();
>>> p.setBrush(QPalette::Window, Qt::transparent);
>>> mWindow->setPalette(p);
>>
>> Try the window opacity property:
>> http://doc.trolltech.com/4.3/qwidget.html#windowOpacity-prop
>>
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>

PNG image

PNG image


Message 5 in thread

On Monday 11 June 2007 00:27:18 DudÃs JÃzsef wrote:
> The picture is result with mWindow->setWindowOpacity( 0.0 ).
>
> I use Kubuntu edgy with kde 3.5.6. In kde application possible to
> setting transparecy. I was download this:
> http://www.linuxlots.com/~siraj/qtclock.html application and compiled.
> This did not was transparent background than black square on my desktop.
> I used qt 4.2.3 and qt 4.3.0rc1 with same result.
>
> Did Somebody resolve similar challenge?

Window opacity with X-Windows requires the presence of a composition manager. 
Usually composition managers nowadays are also window managers at the same 
time. Popular examples include compiz, beryl, kwin (kde3 and kde4) or 
metacity. The latter two have a specific configuration option AFAIK to enable 
window composition, it's not turned on by default. Fortunately all of them 
support the same X window property for window opacity, so 
QWidget::setWindowOpacity should work with all of them.


Simon

Attachment:

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 6 in thread

Thanks!

I make something wrong with kwin setup because is not properly result. 
After I was changed to beryl than setWindowOpacity( value ) is working 
properly. But on this option become the full widget to transparent or 
semi-transparent. I want to transparent just the background and show 
list widget items.


> On Monday 11 June 2007 00:27:18 DudĂĄs JĂłzsef wrote:
>   
>> The picture is result with mWindow->setWindowOpacity( 0.0 ).
>>
>> I use Kubuntu edgy with kde 3.5.6. In kde application possible to
>> setting transparecy. I was download this:
>> http://www.linuxlots.com/~siraj/qtclock.html application and compiled.
>> This did not was transparent background than black square on my desktop.
>> I used qt 4.2.3 and qt 4.3.0rc1 with same result.
>>
>> Did Somebody resolve similar challenge?
>>     
>
> Window opacity with X-Windows requires the presence of a composition manager. 
> Usually composition managers nowadays are also window managers at the same 
> time. Popular examples include compiz, beryl, kwin (kde3 and kde4) or 
> metacity. The latter two have a specific configuration option AFAIK to enable 
> window composition, it's not turned on by default. Fortunately all of them 
> support the same X window property for window opacity, so 
> QWidget::setWindowOpacity should work with all of them.
>
>
> Simon
>   

--
 [ signature omitted ] 

Message 7 in thread

Back again.
Finaly I made this list widget. Now the problem just when I working an 
other windows this event do not refresh my widget background. Have any 
idea about this?

Thanks!
dj


> Thanks!
>
> I make something wrong with kwin setup because is not properly result. 
> After I was changed to beryl than setWindowOpacity( value ) is working 
> properly. But on this option become the full widget to transparent or 
> semi-transparent. I want to transparent just the background and show 
> list widget items.
>
>
>> On Monday 11 June 2007 00:27:18 DudĂĄs JĂłzsef wrote:
>>  
>>> The picture is result with mWindow->setWindowOpacity( 0.0 ).
>>>
>>> I use Kubuntu edgy with kde 3.5.6. In kde application possible to
>>> setting transparecy. I was download this:
>>> http://www.linuxlots.com/~siraj/qtclock.html application and compiled.
>>> This did not was transparent background than black square on my 
>>> desktop.
>>> I used qt 4.2.3 and qt 4.3.0rc1 with same result.
>>>
>>> Did Somebody resolve similar challenge?
>>>     
>>
>> Window opacity with X-Windows requires the presence of a composition 
>> manager. Usually composition managers nowadays are also window 
>> managers at the same time. Popular examples include compiz, beryl, 
>> kwin (kde3 and kde4) or metacity. The latter two have a specific 
>> configuration option AFAIK to enable window composition, it's not 
>> turned on by default. Fortunately all of them support the same X 
>> window property for window opacity, so QWidget::setWindowOpacity 
>> should work with all of them.
>>
>>
>> Simon
>>   
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>

#include <QtGui>
#include "transparentlistwidget.h"

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	
	transparentListWidget* mWindow = new transparentListWidget( 0 );
	mWindow->setGeometry( 0, 530, 1024, 175 );
	mWindow->setBackground();
	
	mWindow->setViewMode( QListView::IconMode );
	mWindow->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	mWindow->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	mWindow->setFlow( QListView::LeftToRight );
	mWindow->setWrapping( FALSE );
	mWindow->setFrameShape( QFrame::NoFrame );
	//mWindow->setWindowFlags( Qt::FramelessWindowHint );
	
	mWindow->setAttribute( Qt::WA_NoSystemBackground );
	QListWidgetItem* wi1 = new QListWidgetItem( QApplication::tr( "\nOrders" ), mWindow );

	wi1->setBackground( QBrush(  QColor( Qt::white ) ) );
	wi1->setSizeHint( QSize( 150, 170 ) );
	wi1->setTextAlignment( Qt::AlignTop + Qt::AlignHCenter );

	mWindow->addItem( wi1 );
	
	mWindow->show();

	return app.exec();
}
#include "transparentlistwidget.h"
#include "transparentlistwidget.h"

#include <QPixmap>
#include <QPalette>
#include <QApplication>
#include <QDesktopWidget>

#include <X11/Xlib.h>

transparentListWidget::transparentListWidget( QWidget *parent )
	: QListWidget( parent )
{
	p = palette();
}


transparentListWidget::~transparentListWidget()
{
}


bool transparentListWidget::x11Event( XEvent * e )
{
	if ( e->type == FocusIn || e->type == FocusOut )
		setBackground();
	return QListWidget::x11Event( e );
}


void transparentListWidget::setBackground()
{
	pix = QPixmap::grabWindow( QApplication::desktop()->winId(), geometry().x(), geometry().y(), geometry().width(), geometry().height() );
	p.setBrush( QPalette::Base, pix );
	setPalette(p);
}
#ifndef TRANSPARENTLISTWIDGET_H
#ifndef TRANSPARENTLISTWIDGET_H
#define TRANSPARENTLISTWIDGET_H

#include <QListWidget>

class QPixmap;
class QPalette;

class transparentListWidget : public QListWidget
{
Q_OBJECT
public:
    transparentListWidget( QWidget *parent );
    ~transparentListWidget();

    void setBackground();

protected:
    virtual bool x11Event ( XEvent* );

private:
    QPixmap pix;
    QPalette p;
};

#endif
CONFIG += qt debug
HEADERS += transparentlistwidget.h

SOURCES += main.cpp
SOURCES += transparentlistwidget.cpp

MOC_DIR += .moc
OBJECTS_DIR += .obj
UI_DIR += .ui