Results 1 to 8 of 8

Thread: How to transform a rect qwidget to trapezium ?

  1. #1
    Join Date
    Jun 2011
    Posts
    45
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to transform a rect qwidget to trapezium ?

    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!

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to transform a rect qwidget to trapezium ?

    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.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jun 2011
    Posts
    45
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to transform a rect qwidget to trapezium ?

    Quote Originally Posted by amleto View Post
    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

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to transform a rect qwidget to trapezium ?

    Do you want to change the shape of the widget or just the image on the widget?

  5. #5
    Join Date
    Jun 2011
    Posts
    45
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to transform a rect qwidget to trapezium ?

    Quote Originally Posted by ChrisW67 View Post
    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

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to transform a rect qwidget to trapezium ?

    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.

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to transform a rect qwidget to trapezium ?

    Or you could widget inside graphics view,, and apply transformations you need

  8. #8
    Join Date
    Jun 2011
    Posts
    45
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to transform a rect qwidget to trapezium ?

    Quote Originally Posted by aamer4yu View Post
    Or you could widget inside graphics view,, and apply transformations you need
    I have thought about this before ,but not let it work.

Similar Threads

  1. transform() vs pos() for QGraphicsItem
    By aalexei in forum Qt Programming
    Replies: 9
    Last Post: 13th November 2012, 23:34
  2. Transform widget with the mouse
    By puch71 in forum Newbie
    Replies: 1
    Last Post: 31st January 2011, 07:36
  3. Distance Transform on a QImage
    By Franckesh in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2010, 08:58
  4. How to transform image like warp
    By yycking in forum Qt Programming
    Replies: 2
    Last Post: 10th December 2009, 08:35
  5. understanding QwtPlot::transform()
    By b.mourat in forum Qwt
    Replies: 1
    Last Post: 25th May 2008, 07:43

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.