QT学習---3つのスライドバーでtextEditの下地を制御

1065 ワード

#include 
#pragma execution_character_set("utf-8");


add::add(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);


	connect(ui.SliderRed, SIGNAL(valueChanged(int)), this, SLOT(on_SliderRed_valueChanged(int)));
	connect(ui.SliderGreen, SIGNAL(valueChanged(int)), this, SLOT(on_SliderRed_valueChanged(int)));
	connect(ui.SliderBlue, SIGNAL(valueChanged(int)), this, SLOT(on_SliderRed_valueChanged(int)));
	connect(ui.SliderAlpha, SIGNAL(valueChanged(int)), this, SLOT(on_SliderRed_valueChanged(int)));

}

void add::on_SliderRed_valueChanged(int value)
{
//	//  Red、Green、Blue        textEdit   
	Q_UNUSED(value);
	QColor color;
	int R = ui.SliderRed->value();
	int G = ui.SliderGreen->value();
	int B = ui.SliderBlue->value();
	int alpha = ui.SliderAlpha->value();
	color.setRgb(R, G, B, alpha); //   QColor   setRgb ()      
	QPalette pal = ui.textEdit->palette();
	pal.setColor(QPalette::Base, color); //    
	ui.textEdit->setPalette(pal);
}

connectを使わずにデザイナーに直接接続できます