L
L
levotskiy2016-11-25 12:49:37
Qt
levotskiy, 2016-11-25 12:49:37

How to programmatically change the color of a QFrame?

Hello. It is necessary to draw frames in the course of execution and change their color. I do it like this:

ffd.frame = new QFrame(ui->VideoLabel);

    QPalette palette;
    QBrush brush(QColor(0, 255, 0, 255));
    brush.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::All, QPalette::Window, brush);
    ffd.frame->setPalette(palette);
    ffd.frame->setGeometry(x,y,width,height);
    ffd.frame->setFrameShape(QFrame::Box);
    ffd.frame->setFrameShadow(QFrame::Plain);
    ffd.frame->setAutoFillBackground(false);
    ffd.frame->setLineWidth(2);
    ffd.frame->show();

The frame is displayed, but its color does not change. Please tell me what I am doing or how to fix it. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2016-12-01
@levotskiy

For any widget there is a setStyle() that eats a string with css style.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question