Results 1 to 12 of 12

Thread: A widged surrounded by another used as a Mask

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    51
    Qt products
    Qt4
    Thanks
    2

    Default A widged surrounded by another used as a Mask

    Good morning,
    i've to develop a map software.
    The map is in a qwidget and all is ok.
    I've to surround the map with a circle angle degree used as mask in which I've to insert some other widget.
    So i need to know how can i insert a circle png over a widget, but i must click the above layer.

    See the picture:
    I've the png picture as the blue mask with transparent hole, the big angle degree cicrle
    I can click the underground map.

    Anyone can help me in showing an example how can i develop a widget sourrounded by another ?
    See the picture attached
    I must use qt 4.2
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: A widged surrounded by another used as a Mask

    Sounds to me more like a use case for a single widget.

    First it draws the inner part, then the "hole" image on top.
    Or even just using a QPainterPath to draw the hole.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2011
    Posts
    51
    Qt products
    Qt4
    Thanks
    2

    Default Re: A widged surrounded by another used as a Mask

    So :
    i have the widget thats draws the map, this widget is connected to a map server that generate the map.
    If i click on map i can zoom pan ecc ecc like any map programs...
    I do not understand how can i draw the hole and the blue borders over this widget.
    Con you be more specific ?
    Consider that in the blue part i've to insert check boxes and button to manage the map...
    Please can you write me a little pseudo-code ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: A widged surrounded by another used as a Mask

    I would draw the blue part in the same widget as the map, i.e. in that widget's paintEvent() method.

    Buttons and other widgets can then easily be placed on top, i.e. as children of the map widget.

    Cheers,
    _

  5. #5
    Join Date
    Sep 2011
    Posts
    51
    Qt products
    Qt4
    Thanks
    2

    Default Re: A widged surrounded by another used as a Mask

    Ok Thank you very much.
    Last question.
    As you can see there are numbers and lines in the circle to represent Degree.
    How can i solve this last problem ?
    I think using a trasparent png is a wrong approach..

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: A widged surrounded by another used as a Mask

    Also doable in paintEvent(), QPainter has methods for drawing text, lines, etc.

    Cheers,
    _

  7. #7
    Join Date
    Sep 2011
    Posts
    51
    Qt products
    Qt4
    Thanks
    2

    Default Re: A widged surrounded by another used as a Mask

    Sorry i cannot yed solved my problem.
    I have a QMainWindow with a QFrame
    in QFrame i have a proprietary qtWidget that draws the map.
    i added this proprietary widget to Qframe with
    Qt Code:
    1. mapFrame->layout()->addwidget(MyProprietaryWidget)
    To copy to clipboard, switch view to plain text mode 
    And all works well i see the map inside the QFrame.
    Now i need to add the circle mask.. to mask some map area as the image attached in thread.
    I think i've to sublcass paintevent of QFrame and not of MainWindow to draw the shapes :
    So
    1) How can i override only QFrame method to add a shape over ?
    Can you explain me with meta code ??? or a simple example ?
    I think after adding the proprietary widget i can draw shapes to mask some map area.
    Thank you

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: A widged surrounded by another used as a Mask

    My suggestion would be to

    1) derive from that map widget,
    2) overwrite paintEvent()
    2a) call the base class paintEvent to draw the map
    2b) draw the mask on top

    I think your other options is to
    1) derive a new class from QWidget
    2) implement paintEvent() to draw the mask
    3) add a layout to the map widget, with spacing set to 0
    4) add an instance of your widget to the layout

    Cheers,
    _

Similar Threads

  1. Dialog Mask
    By thahir1986 in forum Newbie
    Replies: 6
    Last Post: 26th October 2010, 07:06
  2. QLineedit mask
    By sudhansu in forum Qt Programming
    Replies: 11
    Last Post: 12th March 2010, 12:10
  3. Qt 4 expanded mask
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 7th May 2008, 14:21
  4. help with.. numeric mask....
    By ocascante in forum Qt Tools
    Replies: 1
    Last Post: 12th July 2007, 09:53
  5. MainWindow mask
    By SirBabyface in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2007, 15:12

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.