| Qt Programming General Qt programming issues. |
 |

23rd November 2007, 13:20
|
 |
Advanced user
|
|
Join Date: Jan 2007
Location: Paris
Qt products used:
Qt4
Qt platforms used:
MacOS
, Windows
Posts: 340
Thanks: 72
Thanked 1 Time in 1 Post
|
|
Round window
Hey there,
I'm trying to display a window widget with rounded edges.
I've tryed with setMask + specifying a mask, but the result is not convincing.
Qt Code:
1
2
3
4
5
| QRect maskRect(rect().x() + 1, rect().y() + 1,
rect().width() - 1, rect().height() - 1);
setMask(QRegion(ZePainterController::get()->DrawRoundRect(maskRect,
2000 / maskRect.width(), 2000 / maskRect.height()).toFillPolygon().toPolygon())); |
Don't know If I should use a mask bitmap ?
Last edited by bunjee; 23rd November 2007 at 14:33.
|

25th November 2007, 11:20
|
 |
Advanced user
|
|
Join Date: Jan 2007
Location: Paris
Qt products used:
Qt4
Qt platforms used:
MacOS
, Windows
Posts: 340
Thanks: 72
Thanked 1 Time in 1 Post
|
|
Re: Round window
Anybody has a code snipet for this ?
|

25th November 2007, 12:03
|
|
Advanced user
|
|
Join Date: Feb 2006
Location: Munich, Germany
Qt products used:
Qt3
, Qt4
, Qt/Embedded
, Qtopia
Qt platforms used:
MacOS
, Unix/X11
, Windows
Posts: 452
Thanks: 0
Thanked 94 Times in 88 Posts
|
|
Re: Round window
QwtDial ( http://qwt.sourceforge.net/class_qwt_dial.html ) is such a widget. Look at the code of QwtDial::updateMask.
HTH,
Uwe
|

25th November 2007, 13:51
|
|
Expert
|
|
Join Date: Feb 2006
Location: Romania
Qt products used:
Qt4
Qt platforms used:
Unix/X11
, Windows
Posts: 2,744
Thanks: 8
Thanked 518 Times in 512 Posts
|
|
Re: Round window
Quote:
Originally Posted by Uwe
|
Unfortunately that won't work for windows. There is no antialiasing done for top-level windows. For an alternative, see this http://www.qtcentre.org/forum/f-qt-s...sses-9301.html.
|

25th November 2007, 20:23
|
 |
Advanced user
|
|
Join Date: Jan 2007
Location: Paris
Qt products used:
Qt4
Qt platforms used:
MacOS
, Windows
Posts: 340
Thanks: 72
Thanked 1 Time in 1 Post
|
|
Re: Round window
I've coded rounded painting path to use with my mask :
Qt Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| QPainterPath path;
path.moveTo(r.x() + 7, r.y());
path.lineTo(r.x() + r.width() - 7, r.y());
// Upper right
path.lineTo(r.x() + r.width() - 6, r.y() + 1);
path.lineTo(r.x() + r.width() - 5, r.y() + 1);
path.lineTo(r.x() + r.width() - 1, r.y() + 5);
path.lineTo(r.x() + r.width() - 1, r.y() + 6);
path.lineTo(r.x() + r.width(), r.y() + 7);
path.lineTo(r.x() + r.width(), r.y() + r.height() - 7);
// Lower right
path.lineTo(r.x() + r.width() - 1, r.y() + r.height() - 6);
path.lineTo(r.x() + r.width() - 1, r.y() + r.height() - 5);
path.lineTo(r.x() + r.width() - 5, r.y() + r.height() - 1);
path.lineTo(r.x() + r.width() - 6, r.y() + r.height() - 1);
path.lineTo(r.x() + r.width() - 7, r.y() + r.height());
path.lineTo(r.x() + 7, r.y() + r.height());
// Lower left
path.lineTo(r.x() + 6, r.y() + r.height() - 1);
path.lineTo(r.x() + 5, r.y() + r.height() - 1);
path.lineTo(r.x() + 1, r.y() + r.height() - 5);
path.lineTo(r.x() + 1, r.y() + r.height() - 6);
path.lineTo(r.x(), r.y() + r.height() - 7);
path.lineTo(r.x(), r.y() + 7);
// Upper left
path.lineTo(r.x() + 1, r.y() + 6);
path.lineTo(r.x() + 1, r.y() + 5);
path.lineTo(r.x() + 5, r.y() + 1);
path.lineTo(r.x() + 6, r.y() + 1);
path.lineTo(r.x() + 7, r.y()); |
Here is my paint event and my resize event on my main widget :
Qt Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| void ZeMessengerWindow::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
//painter.setRenderHint(QPainter::Antialiasing, true);
QPen pen;
pen.setBrush(ZeStyle::get()->getBorderColor());
painter.setPen(pen);
painter.setBrush(QColor(0, 0, 0, 0));
QRect rectBack(rect().x(), rect().y(),
rect().width() - 1, rect().height() - 1);
ZePainterController::get()->DrawRoundRect(painter, rectBack);
}
//=============================================================================
//=============================================================================
void ZeMessengerWindow::resizeEvent(QResizeEvent * event)
{
setMask(QRegion(ZePainterController::get()->DrawRoundRect(rect()).toFillPolygon().toPolygon()));
} |
The top corners are working fine, unfortunately I have the following bug on the lower corners :
Top :
Bottom :
It's like the mask was antialiased or something
|
 |
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 03:39.
|