diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 6b902b4485..a3b63dbfe9 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -306,8 +306,8 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, wxEVT_SEARCH, m_searchBitmap); - SetBackgroundColour( m_text->GetBackgroundColour() ); m_text->SetBackgroundColour(wxColour()); + SetBackgroundColour( m_text->GetBackgroundColour() ); RecalcBitmaps(); diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 32e938d707..c1483c696e 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -222,14 +222,16 @@ void wxQtDCImpl::SetBackground(const wxBrush& brush) { m_backgroundBrush = brush; + // For consistency with the other ports: clearing the dc with + // invalid brush (Qt::NoBrush) should use white colour (which + // happens to be the default colour in Qt too) instead of no + // colour at all. + if (!m_backgroundBrush.IsOk()) + m_backgroundBrush = *wxWHITE_BRUSH; + if (m_qtPainter->isActive()) { - // For consistency with the other ports: clearing the dc with - // invalid brush (Qt::NoBrush) should use white colour (which - // happens to be the default colour in Qt too) instead of no - // colour at all. - m_qtPainter->setBackground( - brush.IsOk() ? brush.GetHandle() : Qt::white); + m_qtPainter->setBackground(m_backgroundBrush.GetHandle()); } } diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 2a7d64c6d4..eed343f218 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -1294,8 +1294,11 @@ bool wxWindowQt::SetBackgroundColour(const wxColour& colour) if ( !wxWindowBase::SetBackgroundColour(colour) ) return false; - QWidget *widget = QtGetParentWidget(); - wxQtChangeRoleColour(widget->backgroundRole(), widget, colour); + if ( colour.IsOk() ) + { + QWidget *widget = QtGetParentWidget(); + wxQtChangeRoleColour(widget->backgroundRole(), widget, colour); + } return true; }