[Interest] First Paint Event: custom shaped widget
annulen at yandex.ru
Mon Feb 24 16:19:48 CET 2014
24.02.2014, 19:13, "Sensei" <senseiwa at gmail.com>:
> Dear all,
> in a previous post (Masked widget glitch) I asked suggestions about
> making an arrow-like widget (see picture in ). The old and bad code
> used a mask, but it had a glitch, as you see in the picture; however,
> the workaround was easy: doing show, hide, show. Ugly but it worked.
> I was suggested to move my code to a new QWidget subclass, painting the
> background, but now I'm finding it hard to create even the simplest form.
> What I've achieved so far is very lousy (see picture in ): the ugly
> hack I've used before seems better than this one.
> Can anyone help me understand how to draw a good-looking widget?
You should enable antialiasing - it's generally impossible to draw good-looking
triangular shapes without it.
> Thanks & Cheers!
>  https://dl.dropboxusercontent.com/u/15635416/mask.png
>  https://dl.dropboxusercontent.com/u/15635416/paint.png
> ToolWindow::ToolWindow(QWidget *parent, QWidget *follow) :
> QWidget(parent, Qt::FramelessWindowHint)
> void ToolWindow::paintEvent(QPaintEvent *event)
> QPainter p(this);
> const int h = 10;
> const int w = 12;
> QPoint path;
> path = QPoint( 0, h);
> path = QPoint( w , h);
> path = QPoint( w * 2, 0);
> path = QPoint( w * 3, h);
> path = QPoint(width(), h);
> path = QPoint(width(), height());
> path = QPoint( 0, height());
> p.drawPolygon(path, 7);
> Interest mailing list
> Interest at qt-project.org
More information about the Interest