Merge branch 'qt-bgcol-fixes'

Make setting background colour in wxQt more consistent with the other
ports and fix it for wxSearchCtrl.

Closes #23170, #24315.
This commit is contained in:
Vadim Zeitlin 2024-02-13 22:03:35 +01:00
commit 47b011c665
3 changed files with 14 additions and 9 deletions

View file

@ -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();

View file

@ -222,14 +222,16 @@ void wxQtDCImpl::SetBackground(const wxBrush& brush)
{
m_backgroundBrush = 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);
if (!m_backgroundBrush.IsOk())
m_backgroundBrush = *wxWHITE_BRUSH;
if (m_qtPainter->isActive())
{
m_qtPainter->setBackground(m_backgroundBrush.GetHandle());
}
}

View file

@ -1294,8 +1294,11 @@ bool wxWindowQt::SetBackgroundColour(const wxColour& colour)
if ( !wxWindowBase::SetBackgroundColour(colour) )
return false;
if ( colour.IsOk() )
{
QWidget *widget = QtGetParentWidget();
wxQtChangeRoleColour(widget->backgroundRole(), widget, colour);
}
return true;
}