Results 1 to 8 of 8

Thread: Custom Shape Widget (resize)

  1. #1
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Unhappy Custom Shape Widget (resize)

    Hi, I try looking into the forum to see if this have been post before. But could not found any.
    I needed to create a custom shape widget just like the tux example that come with qt.
    I accomplish that.
    Now I need to add resize functionality to the widget. I am lost here. How can I maintain the shape of mask that is set by the image when the user resize the widget?
    My image has a particular rouded in the edge shape, so i would need to add the resize functionality, and that when the user resize the widget this shape maintain even if the user resize the widget a lot.
    Something like MSN messenger on windows.
    Does some one have some kind of code the resembles this functionality. Or some examples?
    Please, any kind of help in this will be much appreciated
    Thanks in advance
    CJC

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

    Default Re: Custom Shape Widget (resize)

    I guess it depends on the contents of your widget. Assuming it is an image, you can scale the image and convert it into a mask which you can then apply. If it's not an image but a set of widgets, you can probably get a list of regions and paint the mask according to those regions. As a last resort you can redirect painting of your widget to some pixmap and then use the pixmap as a mask (provided that it'll keep its transparent background, but it depends on the widget itself).

  3. #3
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Custom Shape Widget (resize)

    Hi!
    Thanks for the reply.
    Do you think thats that the best way?
    By Scaling the image, wont this loose a lot of resolution, and make the mask look bad?
    Isn't there a way to resize the mask when i need it, but that its maintain the same shape of polygon give it by the image? Something just like changing the hight and weight values of the mask?
    What could be the best way to accomplish what it need?
    Thanks in advance
    CJC

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

    Default Re: Custom Shape Widget (resize)

    Quote Originally Posted by PiXeL16 View Post
    By Scaling the image, wont this loose a lot of resolution, and make the mask look bad?
    Maybe I was a bit unclear... If your widget is a label that shows some kind of image and when a resize happens the widget is resized as well, then you can simply convert that resized widget to a mask which can be directly applied on the widget.

    Isn't there a way to resize the mask when i need it, but that its maintain the same shape of polygon give it by the image? Something just like changing the hight and weight values of the mask?
    If the mask (image) is a vector then you can simply scale.

  5. #5
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Custom Shape Widget (resize)

    Hi, Thanks for the reply.
    Well yeah, my widget is not a label, is a qmainwindow that i use to show my application, just like the Tux Example.
    I try some solutions but could only get the the result that i wanted by scaling the image.
    It loose some resolutions when its very big and the mask looks kind of weird. But at least it work.
    If someone has a better way of doing this please let me know
    Thanks again
    CJC

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

    Default Re: Custom Shape Widget (resize)

    Did you try the solution with fetching rectangles of all child windows and using them to draw the mask?

  7. #7
    Join Date
    Feb 2007
    Posts
    28
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Custom Shape Widget (resize)

    Yes, but that wont give me the custom shape given by the alphas of the image, it will just return the actual size all the child's, wish are square.
    So I need to do this with and image. Do someone know if support for svg images is good with qt?
    Could I use svg images just like regular pixmaps?
    Thanks
    CJC.

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

    Default Re: Custom Shape Widget (resize)

    Quote Originally Posted by PiXeL16 View Post
    Yes, but that wont give me the custom shape given by the alphas of the image, it will just return the actual size all the child's, wish are square.
    But if you are using images, then there shouldn't be any problem... Just make sure you create the mask from the image you will actually display (so don't scale twice - once for the image itself and once for the mask - use the already scaled image). I think there are examples on the forum how to do that. Could you show the actual code which doesn't work for you?

    So I need to do this with and image. Do someone know if support for svg images is good with qt?
    Depends what you mean by "good"

    Could I use svg images just like regular pixmaps?
    No, these are not pixmaps. You'd have to do a conversion first.

Similar Threads

  1. Replies: 1
    Last Post: 5th November 2006, 23:50
  2. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 10:05
  3. Custom Widget Plugin Analog Clock
    By kemp in forum Qt Programming
    Replies: 8
    Last Post: 11th August 2006, 13:22
  4. Replies: 3
    Last Post: 12th April 2006, 08:20
  5. Replies: 4
    Last Post: 24th March 2006, 22:50

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.