procedure TForm1.FormShow(Sender: TObject);
type
TQPaletteColorRole = QPaletteWindowText..QPaletteToolTipText;
const
AppPalette: array[TQPaletteColorRole] of TColorRef = (
$eeeeee, $353535, $4b4b4b, $404040, $232323, $2c2c2c, $eeeeee, $0000ff,
$eeeeee, $282828, $353535, $2d2d2d, $a75824, $ffffff, $ff5500, $ff5500,
$353535, $000000, $2d2d2d, $eeeeee);
var
Check: QCheckBoxH;
S: WideString;
var
Palette: QPaletteH;
QColor: TQColor;
ColorRole: TQPaletteColorRole;
List: QListWidgetH;
Item: QListWidgetItemH;
RawWindow: QMainWindowH;
begin
S := 'Raw QT';
// Create raw window
RawWindow := QMainWindow_Create;
QWidget_resize(RawWindow, Scale96ToScreen(220), Scale96ToScreen(150));
// Raw checkbox
Check := QCheckBox_Create(@S, RawWindow);
QWidget_setGeometry(Check, Scale96ToScreen(10), Scale96ToScreen(10),
Scale96ToScreen(200), Scale96ToScreen(20));
QWidget_show(Check);
// Raw listbox with checkboxes
List := QListWidget_Create(RawWindow);
QWidget_setGeometry(List, Scale96ToScreen(10), Scale96ToScreen(40),
Scale96ToScreen(200), Scale96ToScreen(100));
Item := QListWidgetItem_Create(@S, List);
QListWidgetItem_setFlags(Item, QListWidgetItem_flags(Item) or QtItemIsUserCheckable);
QListWidgetItem_setCheckState(Item, QtUnchecked);
Item := QListWidgetItem_Create(@S, List);
QListWidgetItem_setFlags(Item, QListWidgetItem_flags(Item) or QtItemIsUserCheckable);
QListWidgetItem_setCheckState(Item, QtChecked);
QWidget_show(List);
// Show raw window
QWidget_show(RawWindow);
// Set default application palette
Palette := QPalette_Create();
try
QColor := Default(TQColor);
for ColorRole := Low(ColorRole) to High(ColorRole) do
begin
ColorRefToTQColor(AppPalette[ColorRole], QColor);
QPalette_setColor(Palette, ColorRole, @QColor);
end;
QApplication_setPalette(palette);
finally
QPalette_Destroy(Palette);
end;
// Set control-specific palettes
Palette := QPalette_Create();
try
ColorRefToTQColor(clLime, QColor);
QPalette_setColor(Palette, QPaletteWindow, @QColor);
// Update for all QCheckBoxes and QListViews
QApplication_setPalette(Palette, 'QCheckBox');
QApplication_setPalette(Palette, 'QListView');
// Try to set for LCL checkbox?
QWidget_setPalette(TQtWidget(CheckBox1.Handle).Widget, Palette); // Doesn't work
QPalette_setColor(TQtWidget(CheckBox1.Handle).Palette.Handle, // Doesn't work
QPaletteWindow, @QColor);
finally
QPalette_Destroy(Palette);
end;
end;