[Solved] How to fill the widget's background like this,.Please help
-
!http://www.pconline.com.cn/pcedu/sj/pm/photoshop/rm/0510/pic/051012pscdcvr83-04.jpg(this is the background)!
How should i fill the background like the photoshop's edit window on QWidget? I mean draw the lightgray and white squre alternately. Please help me.
-
Thank you for your help. I have solved my problem like this
@
QSize sz(40,40);
QPixmap pix(sz);
QPainter p(&pix);
p.fillRect(0,0,sz.width()/2,sz.height()/2,Qt::lightGray);
p.fillRect(sz.width()/2,0,sz.width()/2,sz.height()/2,Qt::white);
p.fillRect(0,sz.height()/2,sz.width()/2,sz.height()/2,Qt::white);
p.fillRect(sz.width()/2,sz.height()/2,sz.width()/2,sz.height()/2,Qt::lightGray);
this->setBackgroundBrush(QBrush(pix));
@[edit: code highlighting added / Denis Kormalev]
-
Would you mind wrapping that into code tags, please? Thanks!