alanh
24th February 2006, 19:39
Salut,
If you could, please take a look at the attached bitmap. It's a screen capture of a test program for widgets. I have have a simple widget which is simply a combobox plus a fixed-size spacer. The widgets are marked "ComboBox Subclass", but they're QWidget subclasses with a combobox and a spacer. I don't have a clue about why the background is showing through. The heirarchy is this:
main window
...widget stack
.......tab dialog
..........combobox, mycombobox
..........frame1 with no set background
--------------comboBox2, mycombobox2
..........frame2 with orange background
--------------comboBox3, mycombobox3
..........groupbox with no set background
--------------comboBox4, mycombobox4
It's the widget stack that has the blue background set. The background of my widget shows through in every case except where I set the parent frame's background to orange. Anybody know why?? Here's the simple constructor:
#define EDITCOLOR QColor(200,200,100)
ComboBoxSC::ComboBoxSC(QWidget *parent, const char *name)
: QWidget(parent, name)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
comboBox1 = new QComboBox( this, "comboBox1" );
comboBox1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
comboBoxFrameLayout = new QHBoxLayout( this, 0, 0, "comboBoxFrameLayout");
comboBoxFrameLayout->addWidget( comboBox1 );
spacerFixed = new QSpacerItem( 20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed );
comboBoxFrameLayout->addItem( spacerFixed );
setFocusPolicy(QWidget::WheelFocus);
setFocusProxy(comboBox1);
// I've tried a hundred variations on these 2 lines
comboBox1->setPaletteBackgroundColor( EDITCOLOR);
setBackgroundMode( parentWidget()->backgroundMode() );
}
I can't seem to do 3 things:
1) can't make the blank space of my widget match its parent
2) can't change the background color of the combobox by itself
3) can't get a mouse click to give focus to the box. The box will open, but it's won't highlight unless I tab to it.
Any great insights? Thanks for all.
If you could, please take a look at the attached bitmap. It's a screen capture of a test program for widgets. I have have a simple widget which is simply a combobox plus a fixed-size spacer. The widgets are marked "ComboBox Subclass", but they're QWidget subclasses with a combobox and a spacer. I don't have a clue about why the background is showing through. The heirarchy is this:
main window
...widget stack
.......tab dialog
..........combobox, mycombobox
..........frame1 with no set background
--------------comboBox2, mycombobox2
..........frame2 with orange background
--------------comboBox3, mycombobox3
..........groupbox with no set background
--------------comboBox4, mycombobox4
It's the widget stack that has the blue background set. The background of my widget shows through in every case except where I set the parent frame's background to orange. Anybody know why?? Here's the simple constructor:
#define EDITCOLOR QColor(200,200,100)
ComboBoxSC::ComboBoxSC(QWidget *parent, const char *name)
: QWidget(parent, name)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
comboBox1 = new QComboBox( this, "comboBox1" );
comboBox1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
comboBoxFrameLayout = new QHBoxLayout( this, 0, 0, "comboBoxFrameLayout");
comboBoxFrameLayout->addWidget( comboBox1 );
spacerFixed = new QSpacerItem( 20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed );
comboBoxFrameLayout->addItem( spacerFixed );
setFocusPolicy(QWidget::WheelFocus);
setFocusProxy(comboBox1);
// I've tried a hundred variations on these 2 lines
comboBox1->setPaletteBackgroundColor( EDITCOLOR);
setBackgroundMode( parentWidget()->backgroundMode() );
}
I can't seem to do 3 things:
1) can't make the blank space of my widget match its parent
2) can't change the background color of the combobox by itself
3) can't get a mouse click to give focus to the box. The box will open, but it's won't highlight unless I tab to it.
Any great insights? Thanks for all.