PDA

View Full Version : Qt 4 expanded mask



bunjee
6th May 2008, 19:53
Hey there I'm using a "masked" widget as main window:


/* virtual */ void ZeMessengerWindow::resizeEvent(QResizeEvent * event)
{
QRect maskRect(rect().x(), rect().y(),
rect().width(), rect().height());
setMask(QRegion(ZePainterController::get()->DrawUpRoundRect(maskRect).toFillPolygon().toPolygo n()));
}

Every resizeEvent, I set a mask.
Problem is, when I
- Expand it to occupy the full screen.
- My widget behave as if it has the upper windows frame.
- Thus, my widget isn't really occupying the full screen.

Can I specify an expanded rectangle to my masked widget only ?

wysota
6th May 2008, 21:13
- My widget behave as if it has the upper windows frame.
Because it does. It's just transparent.


Can I specify an expanded rectangle to my masked widget only ?
Start by making your widget frameless by using appropriate window flags.

bunjee
6th May 2008, 22:53
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);

Only problem is, I don't see my Taskbar anymore.

wysota
6th May 2008, 23:48
It's either one or the other... You can artificially move the widget up to skip the frame in the maximized mode, if you want. With fullscreen there is no frame at all, maybe that's your option (although there is no taskbar either).

bunjee
7th May 2008, 14:21
Here is an home made implementation for masked windows:


void ZeMessengerWindow::ShowNormal()
{
if (isWindowMaximized() == true)
{
mWindowMaximized = false;

//showNormal();
move(mOldGeometry.x(), mOldGeometry.y());
resize(mOldGeometry.width(), mOldGeometry.height());
mMaximizeButton->setText(tr("+"));

// Size grips
mSizeGrip1->show();
mSizeGrip2->show();
mSizeGrip3->show();
mSizeGrip4->show();

// Restoring old geometry
mOldGeometry = QRect(-1, -1, -1, -1);
}
}

void ZeMessengerWindow::ShowMaximized()
{
if (isWindowMaximized() == false)
{
//showMaximized();
mWindowMaximized = true;
mOldGeometry = QRect(x(), y(), width(), height());

const QRect rect = QApplication::desktop()->availableGeometry();
setGeometry(QRect(0, 0, rect.width(), rect.height()));
mMaximizeButton->setText(tr("-"));

// Size grips
mSizeGrip1->hide();
mSizeGrip2->hide();
mSizeGrip3->hide();
mSizeGrip4->hide();
}
}