Got it!
Here is the solution...
{
// grab the geometry
QRect fg
= frameGeometry
();
// get some reusable values
int nCaptionHeight = rg.top() - fg.top();
int nFrameWidth = rg.left() - fg.left();
// map the global coords to local for the frame
fg.moveTo(mapFromGlobal(fg.topLeft()));
// create a rectangle for the frame
QRect rectFrame
(fg.
left() - nFrameWidth,
fg.top() - nCaptionHeight,
fg.width() + ( nFrameWidth * 2 ),
fg.height() + ( nCaptionHeight + nFrameWidth ) );
// create a region from the frame rectangle
// map the global coords to local for the client area
rg.moveTo(mapFromGlobal(rg.topLeft()));
// move the rect to 0,0
// create a region from the client rect
// set a mask to be the frame region minus the client region
setMask( regionFrame - regionClient );
}
void resizeEvent(QResizeEvent *e)
{
QDialog::resizeEvent(e);
// grab the geometry
QRect fg = frameGeometry();
QRect rg = geometry();
// get some reusable values
int nCaptionHeight = rg.top() - fg.top();
int nFrameWidth = rg.left() - fg.left();
// map the global coords to local for the frame
fg.moveTo(mapFromGlobal(fg.topLeft()));
// create a rectangle for the frame
QRect rectFrame(fg.left() - nFrameWidth,
fg.top() - nCaptionHeight,
fg.width() + ( nFrameWidth * 2 ),
fg.height() + ( nCaptionHeight + nFrameWidth ) );
// create a region from the frame rectangle
QRegion regionFrame( rectFrame );
// map the global coords to local for the client area
rg.moveTo(mapFromGlobal(rg.topLeft()));
// move the rect to 0,0
rg.moveTo( QPoint(0,0) );
// create a region from the client rect
QRegion regionClient( rg );
// set a mask to be the frame region minus the client region
setMask( regionFrame - regionClient );
}
To copy to clipboard, switch view to plain text mode
You will probably recognize some of this code from this thread.
Many thanks to J-P Nurmi for laying the foundation...
It just took a bit to figure out that my problem was the math (e.g. negative numbers to allow the caption bar (since QPoint(0,0) is the upper left corner of the client area).
Thanks again JPN
This is what I was looking for...
Bookmarks