Results 1 to 5 of 5

Thread: how to change shape of Qwidget??

  1. #1
    Join Date
    Apr 2009
    Posts
    58
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to change shape of Qwidget??

    hi all,
    I want to change the shape of qwidget.I want my widget to have round rectangle shape.
    How to do it??

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to change shape of Qwidget??


  3. #3
    Join Date
    Apr 2009
    Posts
    58
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to change shape of Qwidget??

    hi,
    I have tried setMask but didnt get the desired result
    How can i do it .Can you explain more.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to change shape of Qwidget??

    did you see an example in QTDIR/examples/widgets/shapedclock?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Apr 2009
    Posts
    21
    Thanked 3 Times in 2 Posts

    Default Re: how to change shape of Qwidget??

    Here is my example:

    Qt Code:
    1. void ShapedMenu::roundCorner()
    2. {
    3. QPixmap pixmap(size());
    4. QPainter painter(&pixmap);
    5. painter.fillRect(pixmap.rect(), Qt::white);
    6. painter.setBrush(Qt::black);
    7. painter.drawRoundRect(pixmap.rect(), 10, 10);
    8. setMask(pixmap.createMaskFromColor(Qt::white));
    9. }
    To copy to clipboard, switch view to plain text mode 

    You could customize the pixmap by design it with Photoshop, CorelDRAW, etc.
    Welcome to My Chinese Qt Blog (Google Translate Integrated) - http://www.xlrw.co.cc
    Dedicated to make Qt popular in Chinese-speaking society.

Similar Threads

  1. Replies: 0
    Last Post: 11th November 2008, 15:36
  2. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  3. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25
  4. Change the shape of a frame.
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 06:40
  5. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.