Results 1 to 2 of 2

Thread: Flipping QWidget

  1. #1
    Join Date
    Sep 2009
    Posts
    49
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Flipping QWidget

    I am sub classing QWidget and doing some custom painting in paint event. By default top left is considered as (0,0) and bottom right is (1,1). Is it possible to change the coordinate system so that bottom left will become (0,0) and top right (1,1)

    I tried in paint event:
    Qt Code:
    1. painter.scale(1,-1)
    To copy to clipboard, switch view to plain text mode 
    Doesn't work?

    When clicking down on widget how do I retrieve the color at point? For example I am drawing a gradient in paint event and when I click down, (mouseDownEvent) I need to get the color of that pixel.

    Similarly how do I retrieve the color at mouse down in QGraphicsViewand QGraphicsScene.
    Last edited by prashant; 10th November 2009 at 08:32.
    Prashant


    qt-sdk-win-opensource-2009.03.1.exe
    Python 2.6.3
    PyQt-Py2.6-gpl-4.6-1
    Win XP, 32 Bit

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Flipping QWidget

    Is it possible to change the coordinate system so that bottom left will become (0,0) and top right (1,1)
    Yes, by using setWindow().
    Read the docs about logical and physical coordinates:
    http://doc.trolltech.com/4.4/coordsy...ort-conversion
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Promoting the parent QWidget of a QWidget form
    By extrakun in forum Qt Tools
    Replies: 6
    Last Post: 16th April 2010, 14:19
  2. Adding a scrollbar to a QWidget
    By qtUser500 in forum Newbie
    Replies: 13
    Last Post: 2nd September 2009, 19:48
  3. Replies: 0
    Last Post: 11th November 2008, 15:36
  4. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  5. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05

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.