Solved 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 ?
-
like this I need to do
How to do ?
If anyone has any example related to this plz share -
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)); }
-
Oh,,actually i haven't created class for tab2 widget
QPainter myellip(this);
can't i do like this-> QPainter myellip(ui.tab2); -
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);
-
@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 -
Hi
If you data is from a View, its actually from its model.but was it a question or ?
QPainter has all the functions you need to do it.
except maybe for the small arrow inside the circle