Unable to view rectangle(red color) drawn using Qpainter when the window background is set to black color
-
i want to draw a red color rectangle on a black backgrounded window but unable to view the rectangle. My code is as below:
void MainWindow::paintEvent(QPaintEvent *e)
{
QPainter painter(this);QPen linepen(Qt::red);
linepen.setWidth(5);painter.setPen(linepen);
painter.drawRect(230,120,121,71);
} -
Hi and welcome to devnet,
The pen is used for the lines and outlines. If you want to have a rect in red, either use a red brush or use the fillRect function.
-
Using red brush or fillRect is making inner part of the rectangle also filled up with red color. I want only the border of the rectangle to be filled with red and inner part to be transparent.
-
Then set the brush to Qt::transparent.