Drawing circles using QPainter
-
Hi,
1->I need to draw circles based on user value in a table(Qtableview).
2->draw/connect two circle using line (CD)
3->shows direction in circle like arc kind (--->)
4->i need to display this circle in my tab2 (Qtabwidget)
How to do this ?like simply i can do like this:
{ QPainter myellip(this); QPen epen; int x = 10; epen.setWidth(3); epen.setColor(Qt::yellow); epen.setBrush(Qt::SolidPattern); // myellip.setBrush(Qt::SolidPattern); myellip.setPen(epen); myellip.drawEllipse(QRect(150, 300, 100, 100)); }How can i do these all ? How to approach ?
-
Hi,
Do you mean as an overlay ?
-
void table_model::paintEvent(QPaintEvent* event) { QPainter myellip(this); QPen epen; int x = 10; epen.setWidth(3); epen.setColor(Qt::yellow); epen.setBrush(Qt::SolidPattern); // myellip.setBrush(Qt::SolidPattern); myellip.setPen(epen); myellip.drawEllipse(QRect(150, 300, 100, 100)); }how can i display this circle in my tab2 (Qtabwidget)
-
void table_model::paintEvent(QPaintEvent* event) { QPainter myellip(this); QPen epen; int x = 10; epen.setWidth(3); epen.setColor(Qt::yellow); epen.setBrush(Qt::SolidPattern); // myellip.setBrush(Qt::SolidPattern); myellip.setPen(epen); myellip.drawEllipse(QRect(150, 300, 100, 100)); }how can i display this circle in my tab2 (Qtabwidget)
@n-2204
Hi,
maybe try use function paintEvent() in tab2 ie:void tab2::paintEvent(QPaintEvent* event) { QPainter myellip(this); QPen epen; int x = 10; epen.setWidth(3); epen.setColor(Qt::yellow); epen.setBrush(Qt::SolidPattern); // myellip.setBrush(Qt::SolidPattern); myellip.setPen(epen); myellip.drawEllipse(QRect(150, 300, 100, 100)); } -
No, you cannot paint on another widget.
-
Hi
well you can paint on a pixmap and show in a QLabelQPixmap pix(200, 200); pix.fill(Qt::blue); QPainter painter (&pix); painter.setRenderHint(QPainter::Antialiasing, true); ..... draw ... ui->label->setPixmap(pix); -
Hi
well you can paint on a pixmap and show in a QLabelQPixmap pix(200, 200); pix.fill(Qt::blue); QPainter painter (&pix); painter.setRenderHint(QPainter::Antialiasing, true); ..... draw ... ui->label->setPixmap(pix); -
@mrjj
ok Thankyou..
using Qpixmap & Qpainter is a good approach to draw the circles as i shared image above and i need to draw arc, lines & input for circle is from Qtableview
