PDA

View Full Version : Why blur effect on only one widget at a time?



nrabara
26th April 2010, 07:28
Hi,

I am using 4.6.2 on linux, In my widget I have few pushbuttons.
Now if i set blue effect by setting following.



ui->pushbutton_1->setGraphicsEffect(blur);
ui->pushbutton_2->setGraphicsEffect(blur);
ui->pushbutton_3->setGraphicsEffect(blur);
ui->pushbutton_4->setGraphicsEffect(blur);
ui->pushbutton_5->setGraphicsEffect(blur);

it will show blur effect only on last pushbutton i.e. pushbutton_5 .

now if I do,
ui->pushbutton_1->setGraphicsEffect(blur);
ui->pushbutton_4->setGraphicsEffect(blur);
ui->pushbutton_5->setGraphicsEffect(blur);
ui->pushbutton_2->setGraphicsEffect(blur);
ui->pushbutton_3->setGraphicsEffect(blur);

it will show blur effect only on pushbutton_3


so every time it will show blur effect on last widget only.

Is there any way to show this blur effect on several widget(pushbuttons in my case) simultaneously?

aamer4yu
26th April 2010, 07:58
From the docs -

void QWidget::setGraphicsEffect ( QGraphicsEffect * effect )
The setGraphicsEffect function is for setting the widget's graphics effect.

Sets effect as the widget's effect. If there already is an effect installed on this widget, QWidget will delete the existing effect before installing the new effect.

If effect is the installed on a different widget, setGraphicsEffect() will remove the effect from the widget and install it on this widget.

QWidget takes ownership of effect. [This explains why your code applies effect to the last widget ;) ]

Note: This function will apply the effect on itself and all its children.

So in short, you will need to create a seperate object of graphics effect for each widget to apply.
Or alternatively you can apply the effect to the parent item.

nrabara
26th April 2010, 11:13
From the docs -
Or alternatively you can apply the effect to the parent item.

I have applied blur effect ot parent widget, my parent widget contains 18 pushbuttons and 1 label.
I am able to manage blur on all the pushbuttons, but this makes pushbutton slower. ( we can differential click on pushbutton with blur applied to parent widget and without blur effect.)

I am using on Linux platform with ARM9 400Mhz CPU.

Is Graphics effect eat more CPU that degrads overall performance, or its a property of Graphics effect??

aamer4yu
26th April 2010, 11:30
ui->pushbutton_1->setGraphicsEffect(blur);
ui->pushbutton_2->setGraphicsEffect(blur);
ui->pushbutton_3->setGraphicsEffect(blur);
ui->pushbutton_4->setGraphicsEffect(blur);
ui->pushbutton_5->setGraphicsEffect(blur);

it will show blur effect only on last pushbutton i.e. pushbutton_5 .

now if I do,
ui->pushbutton_1->setGraphicsEffect(blur);
ui->pushbutton_4->setGraphicsEffect(blur);
ui->pushbutton_5->setGraphicsEffect(blur);
ui->pushbutton_2->setGraphicsEffect(blur);
ui->pushbutton_3->setGraphicsEffect(blur);

it will show blur effect only on pushbutton_3
From above doesnt seem you are applying effect only to parent item !

nrabara
26th April 2010, 13:20
Sorry I just forget to put code.


this->setGraphicsEffect(blur); // instead of ui->pushbutton_5->setGraphicsEffect(blur).