C++ (Qt)// make active/inactive palettes same to avoid redraw when focus is changedvoid SyncPalette( QWidget * w ){ QPalette newPalette, oldPalette = w->palette(); int numRoles = (int) QPalette::NColorRoles; for (int role = 0; role < numRoles; ++role) { QPalette::ColorRole role1 = (QPalette::ColorRole) role; if (!newPalette.isBrushSet(QPalette::Active, role1)) newPalette.setBrush(role1, oldPalette.brush(QPalette::Active, role1)); } w->setPalette(newPalette);}