Can't set background color
Unsolved
General and Desktop
-
trying to set background color
example (this work ) :QBrush maska(QColor(48,172,220,120),Qt::SolidPattern); // для маски painter.setBrush(maska); // задаём цвет фона
this call code :
case Qt::Key_A: if(_myTexpr.substrate) setSubstrate(false, 100, 100, 100, 100); else setSubstrate(true, 100, 100, 100, 100); void wgt_line::setSubstrate(bool val, int rgb0, int rgb1, int rgb2, int rgb3 ) { _myTexpr.substrate = val; _myTexpr.substrate_t = true; // включаем датчик qDebug() << "setSubstrate(bool val, int rgb0, int rgb1, int rgb2, int rgb3 )"; _myTexpr. rgb[0] = rgb0; _myTexpr. rgb[1] = rgb1; _myTexpr. rgb[2] = rgb2; _myTexpr. rgb[3] = rgb3; }
and me code :
if(_myTexpr.substrate_t == true) { color_maska.fromRgb(_myTexpr.rgb[0], _myTexpr.rgb[1], _myTexpr.rgb[2], _myTexpr.rgb[3]); // color_maska(_myTexpr.rgb[0], _myTexpr.rgb[1], _myTexpr.rgb[2], _myTexpr.rgb[3]); maska.setColor(color_maska); maska.setStyle(Qt::SolidPattern); // maska(color_maska,Qt::SolidPattern); // для маски qDebug() << "_myTexpr.suqqqqq"; } if(_myTexpr.substrate_t == false) { qDebug() << "_myTexpr.substrate_t1"; color_maska.fromRgb(48,172,220,120); maska.setColor(color_maska); maska.setStyle(Qt::SolidPattern); // maska(color_maska,Qt::SolidPattern); // для маски } // задаём цвет фона if(_myTexpr.substrate == true) painter.setBrush(maska);
For now it can only fill color with zeros which means black color :( how to set background color ???
-
Hi,
Your logic seems wrong. Whether you press A or not, the color is 100, 100, 100, 100.
And then you set the brush only when the color is the above set of numbers.
-
@SGaist said in Can't set background color:
Hi,
Your logic seems wrong. Whether you press A or not, the color is 100, 100, 100, 100.
And then you set the brush only when the color is the above set of numbers.Hi
the color is not set at all, it is 0 0 0 0 by default.
the problem is why the color does not change
this code work
QBrush maska1(QColor(48,172,220,120),Qt::SolidPattern); // для маски painter.setBrush(maska1); // задаём цвет фона
this code not work
QBrush maska; // фон QColor color_maska; // задаём цвет фона color_maska.fromRgb(48,172,220,120); maska.setColor(color_maska); maska.setStyle(Qt::SolidPattern); painter.setBrush(maska);
WHY ?
-
Where are you using that painter ?