PDA

View Full Version : How to transform a rect qwidget to trapezium ?



wshn13
18th June 2012, 08:10
Now there is a normal qwidget on which there is a pixmap shown on ,I want to transform the qwidget to a ctangle ,the left side is same height as the orignal qwidget , I want the right side to be small than the orignal qwidget ,JUST like the qt's offical logo .How can I achive ? Thanks!

amleto
18th June 2012, 08:20
I think there are not many ways to do this. I imagine you will have to create a frame-less widget and use transparency to 'cut out' the bits you do not want.

wshn13
18th June 2012, 09:15
I think there are not many ways to do this. I imagine you will have to create a frame-less widget and use transparency to 'cut out' the bits you do not want.

thanks ,but your method is not I want

ChrisW67
18th June 2012, 09:23
Do you want to change the shape of the widget or just the image on the widget?

wshn13
19th June 2012, 04:35
Do you want to change the shape of the widget or just the image on the widget?
I want change the shape of the widget , not just the image .Any idea ?thx

ChrisW67
19th June 2012, 06:19
There's no three line solution I can see. Derive from the closest widget and provide your own paintEvent(). Essentially you want a perspective transformation applied to your image. You may also need handle mouse events to define a clickable area if that's a requirement.

Bear in mind that the Qt layout system will still consider the widget a rectangular area.

aamer4yu
19th June 2012, 06:24
Or you could widget inside graphics view,, and apply transformations you need :)

wshn13
19th June 2012, 08:17
Or you could widget inside graphics view,, and apply transformations you need :)
I have thought about this before ,but not let it work.