View Full Version : Dialog Mask
thahir1986
24th October 2010, 16:04
Hi Friends,
I checked some of the threads, but in that thread they only discussed about how to remove(mask) the background of the widget.
But i need bring the qdialog the irregular shape that depends on the image we set as backgroud for the widget.
For example i have an image like iphone..my qdialog should be look like iphone and make the remaining thing as tranparent.
Help please.....:(
wysota
24th October 2010, 16:51
Use the image as the mask or set a "translucent background" attribute on your dialog so that only the areas you paint yourself are opaque.
thahir1986
25th October 2010, 06:44
Thank for ur quick reply zen,
i need further clarification...
I have a QDialog.ui ...in that stylesheet property for the QFrame i was set
QFrame
{
background-image: url(:/images/messagebox.png) no-repeat;
}
and in my QDialog constructor
QPixmap pixmap(":/images/messagebox.png");
ui->frame->setMask(pixmap.mask());
QRegion reg(frameGeometry());
reg-=QRegion(geometry());
reg+=childrenRegion();
setMask(reg);
but i got an error
dialog.cpp: In constructor ‘Dialog::Dialog(QWidget*)’:
dialog.cpp:12: error: invalid use of incomplete type ‘struct QBitmap’
/opt/qtsdk-2010.05/qt/include/QtGui/qwindowdefs.h:77: error: forward declaration of ‘struct QBitmap’
make: *** [dialog.o] Error 1
wysota
25th October 2010, 06:49
#include <QBitmap>
But this will not work. You need to set the mask on the top-level widget only (the dialog, not the frame that's in it).
thahir1986
25th October 2010, 07:15
Thanks..It works.
But one silly question finally..
I want to remove the title window of the QDialog, for that i did give the
setAttribute(Qt::FramelessWindowHint, true);
but again i got an error like,
dialog.cpp:14: error: no matching function for call to ‘Dialog::setAttribute(Qt::WindowType, bool)’
/opt/qtsdk-2010.05/qt/include/QtGui/qwidget.h:607: note: candidates are: void QWidget::setAttribute(Qt::WidgetAttribute, bool)
make: *** [dialog.o] Error 1
aahh..i want to learn qt through, but i can't.
wysota
25th October 2010, 21:08
It's a hint not an attribute.
aahh..i want to learn qt through, but i can't.
I suggest to learn C++ first.
thahir1986
26th October 2010, 07:06
I suggest to learn C++ first.
U r correct indeed.. i need learn that first indeed...Could tell me which is the best book to learn c++ crystal clear...?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.