Results 1 to 6 of 6

Thread: Make the QComboBox popup translucent or transparent ?

  1. #1
    Join Date
    Aug 2008
    Posts
    16
    Thanks
    3

    Question Make the QComboBox popup translucent or transparent ?

    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 ebian 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 .

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Make the QComboBox popup translucent or transparent ?

    Quote Originally Posted by charlse View Post
    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?

  3. The following user says thank you to wysota for this useful post:

    charlse (18th August 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    16
    Thanks
    3

    Default Re: Make the QComboBox popup translucent or transparent ?

    Quote Originally Posted by wysota View Post
    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.
    Last edited by charlse; 18th August 2008 at 09:28.

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Make the QComboBox popup translucent or transparent ?

    try this, but (imho) this is imaginary transparency.
    Qt Code:
    1. ...
    2. QComboBox *cb = new QComboBox(this);
    3. cb->addItem("1");
    4. cb->addItem("2");
    5. cb->addItem("3");
    6. cb->addItem("4");
    7. cb->addItem("5");
    8. QPalette pal = cb->view()->palette();
    9. pal.setBrush(QPalette::Base, Qt::transparent);
    10. cb->view()->setPalette(pal);
    11. ...
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to spirit for this useful post:

    charlse (18th August 2008)

  7. #5
    Join Date
    Aug 2008
    Posts
    16
    Thanks
    3

    Default Re: Make the QComboBox popup translucent or transparent ?

    Quote Originally Posted by spirit View Post
    try this, but (imho) this is imaginary transparency.
    Qt Code:
    1. ...
    2. QComboBox *cb = new QComboBox(this);
    3. cb->addItem("1");
    4. cb->addItem("2");
    5. cb->addItem("3");
    6. cb->addItem("4");
    7. cb->addItem("5");
    8. QPalette pal = cb->view()->palette();
    9. pal.setBrush(QPalette::Base, Qt::transparent);
    10. cb->view()->setPalette(pal);
    11. ...
    To copy to clipboard, switch view to plain text mode 
    this can't make the QComboBoxPrivateContainer behind the QAbstractItemView transparent , just make the QAbstractItemView transparent .

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Make the QComboBox popup translucent or transparent ?

    What exactly does the container represent? What is it derived from?

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.