Results 1 to 3 of 3

Thread: color comboBox problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default color comboBox problem

    Hi guys,

    I have a comboBox that displays colors with the last item that displays “other”.

    My code looks like:
    Qt Code:
    1. comboBox_colors->addItem(“”);
    2. comboBox_colors->setItemData(0,Qt::red,Qt::BackgroundColorRole);
    3. comboBox_colors->addItem(“”);
    4. comboBox_colors->setItemData(1,Qt::blue,Qt::BackgroundColorRole);
    5. comboBox_colors->addItem(“”);
    6. comboBox_colors->setItemData(2,Qt::green,Qt::BackgroundColorRole);
    7. …
    8. comboBox_colors->addItem(“other”);
    9. comboBox_colors->setItemData(15,Qt::transparent,Qt::BackgroundColorRole);
    To copy to clipboard, switch view to plain text mode 

    I am having trouble disabling the highlight option because now when I scroll over the colors they change from whatever the color is to the highlight color. I tried changing the highlight color to white but it just changes the color from whatever to white.
    I am also having trouble displaying the selected color in the comboBox when it is minimized. No matter what color is selected it will not display when the comboBox is minimized. So it always has a white background when the comboBox is minimized. The only time when I see something in the comboBox is when “other” is selected because “other” is displayed. Obviously if I put a word in the “” when I add the item, it will get displayed but I want it to display the color and no words.

    If someone could help me out with this, it would be greatly appreciated. I have been suck on this for awhile.


    *Maybe instead of disabling the highlight I can just set it to transparent? How do you change the color of the highlight in a comboBox in code? I only know how to change it using QT designer.*

    I tried:
    Qt Code:
    1. QPalette highlight;
    2. QBrush trans(Qt::transparent);
    3. trans.setStyle(Qt::SolidPattern);
    4. highlight.setBrush(QPalette::Highlight,trans);
    5. comboBox_colors->setPalette(highlight);
    To copy to clipboard, switch view to plain text mode 
    But that makes it white and not transparent.

    Thanks.
    Last edited by chguy2; 20th April 2007 at 16:28.

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15: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
  •  
Qt is a trademark of The Qt Company.