Results 1 to 3 of 3

Thread: background transparency

  1. #1
    Join Date
    Apr 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default background transparency

    hi

    I'm trying to do an Autodesk Sketcbook style pie-menu, where icons hover around a center point without a donut/circle shaped background and selection is marked by a line drawn from center of the pie to cursor position.
    So far, I have everything working, except getting completely rid of the the background. Masking out everything except the icons solves most of the problem, but then I can't draw the line from center to cursor position.
    I have tried setting widget's background color role to point to a transparent color, and setting Qt::WA_NoSystemBackground attribute , but no luck. From one source I understood that transparency does not work on all GUI styles, so I tried chancing that, but that didn't work.

    Do you have any hints how to solve this? I'm using Qt 4.2 (could chance to 4.3 if that helps) on WindowsXP.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: background transparency

    Hello,

    One idea is to paint yourself the entire widget ( overwrite paintEvent() ). For the parts that you want to be transparent you can set the painter opacity to something very small (whatever suites you ).

    You should use setOpacity just to obtain transparency. For the pie shape you should set the painter clip path to a circle( clip everything outside ).

    No time for an example now... Read in the Assistant the QPainter class reference. It should provide enough info.

    Marcel

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: background transparency

    Maybe you should draw the menu (and the line) on a pixmap/image first and use createHeuristicMask() to create a mask which you'll then be able to apply on the widget.

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2006, 18:51
  2. QFrame and its background
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 20:32
  3. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44
  4. Replies: 1
    Last Post: 5th April 2006, 16:44
  5. [QT3+XP] transparency and mouse tracking
    By incapacitant in forum Newbie
    Replies: 9
    Last Post: 17th February 2006, 18:49

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
  •  
Qt is a trademark of The Qt Company.