Answer the question
In order to leave comments, you need to log in
Qt Widgets how to color only one widget?
Hello!
Question: There is one large field where I insert my widgets - different amount, depending on the data.
The rendering takes place in an overridden paintEvent.
You just need to implement the choice of one widget from all the others.
More specifically, I have a flag in the widget: bool isActive;
Further overridden events:
void Widget::focusOutEvent(QFocusEvent *event)
{
isActive = false;
}
void Widget::mousePressEvent(QMouseEvent *event)
{
isActive = true;
if(event->type() == QEvent::WindowDeactivate) isActive = false;
this->update();
}
Answer the question
In order to leave comments, you need to log in
Damn) as usual, everything is banal) forgot to call the update () method :)
bool Widget::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::FocusOut)
{
if (object == this)
{
qDebug() << "Здесь ловим событие focus Out!";
this->isActive = false;
this->update(); // из-за этой строчки я потерял 1,5 часа)
}
}
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question