PDA

View Full Version : Make the QComboBox popup translucent or transparent ?



charlse
18th August 2008, 04:56
Hello all Qt developers:
I used a comboBox on my Application , I want make its popup List translucent or transparent , But I don't know the way .
My Qt version: 4.4.0 my Os :Debian Linux , WIN-CE , Thanks for you suggestion .

NOTE:
I read the source code of the QComboBox , and I found there was a QComboPrivateContainer *container behind the QAbstractItemView object of the popup (/*the popup*/ QComboBox::view());
The style of the QAbstractItemView can be set by "setStyleSheet("background-color: rgba(0,0,0,0);")" ,but the style of the container can't be set by this way , It can be set by"QComboBox::view()->parentWidgetOpacity(0.5)" , but I can't use this , because the WIN-CE doesn't support this .

wysota
18th August 2008, 07:26
but the style of the container can't be set by this way
Why not? You don't know how to do it or it doesn't work?

charlse
18th August 2008, 08:10
Why not? You don't know how to do it or it doesn't work?

For the first , Thanks .
you're right . I don't know the way .

I used "view()->parentWidget()->setStyleSheet("background-color: rgba(200,0,0,0);");"
but the container can't be set transparent , it's black ! But if I change the value of Alpah 255, the background-color of the container is set red .

And could you show me the way ?
Thank you very much.

spirit
18th August 2008, 09:55
try this, but (imho) this is imaginary transparency.


...
QComboBox *cb = new QComboBox(this);
cb->addItem("1");
cb->addItem("2");
cb->addItem("3");
cb->addItem("4");
cb->addItem("5");
QPalette pal = cb->view()->palette();
pal.setBrush(QPalette::Base, Qt::transparent);
cb->view()->setPalette(pal);
...

charlse
18th August 2008, 11:51
try this, but (imho) this is imaginary transparency.


...
QComboBox *cb = new QComboBox(this);
cb->addItem("1");
cb->addItem("2");
cb->addItem("3");
cb->addItem("4");
cb->addItem("5");
QPalette pal = cb->view()->palette();
pal.setBrush(QPalette::Base, Qt::transparent);
cb->view()->setPalette(pal);
...


this can't make the QComboBoxPrivateContainer behind the QAbstractItemView transparent , just make the QAbstractItemView transparent .

wysota
18th August 2008, 16:18
What exactly does the container represent? What is it derived from?