Look at paintEvent() in my example.
You get thin line by drawing a line from top to bottom (not by setting a background or anything).
Then you draw a circle using full width of the widget.
This way you can adjust size of the circle by changing width of the widget.
{
int middle = this->width()/2;
p.setBrush( Qt::NoBrush );
p.setPen( this->palette().foreground().color() ); // change pen width here if you want wider line
p.drawLine( middle, 0, middle, this->height() ); // here you draw the thin lne using default pen (about 1px wide)
p.setBrush( Qt::white );
p.
drawEllipse( QPoint( middle, this
->elipsePosY
), middle
-1, middle
-1 );
// here you draw the circle with radius = width/2}
void LineMarker::paintEvent( QPaintEvent* e )
{
int middle = this->width()/2;
QPainter p( this );
p.setBrush( Qt::NoBrush );
p.setPen( this->palette().foreground().color() ); // change pen width here if you want wider line
p.drawLine( middle, 0, middle, this->height() ); // here you draw the thin lne using default pen (about 1px wide)
p.setBrush( Qt::white );
p.drawEllipse( QPoint( middle, this->elipsePosY ), middle-1, middle-1 ); // here you draw the circle with radius = width/2
}
To copy to clipboard, switch view to plain text mode
Bookmarks