Results 1 to 3 of 3

Thread: To rotate widget

  1. #1
    Join Date
    Sep 2007
    Location
    Pune
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Question To rotate widget

    Hi am Ajit
    I have created a widget of size ellipse
    i want to rotate that ellipse-widget according to the left button mouse move till the left button is down

    To create ellipse size widget, in the constructor i have written the following code

    {
    m_maskedRegion = QRegion(CENTER_X-26, CENTER_Y - 187, 203, 435, QRegion::Ellipse);
    setMask(m_maskedRegion);
    }

    please help me
    is there any function like for the QPainter there is rotate function

  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: To rotate widget

    You have to reimplement the widget's paintevent and rotate the painter and render a pixmap of the widget to the rotated painter. But this way you'll only get a rotated "look" but not "feel". What is the widget anyway?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: To rotate widget

    • Store rotation as member variable
    • reimplement corresponding mouse event handlers to increase/decrease rotation
    • use QPainter::rotate() in paintEvent()

    Of course, you will also have to apply the rotation to the mask as well. You can do that with QMatrix::map(QRegion).
    J-P Nurmi

Similar Threads

  1. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 11:17
  2. transparent background of the main widget
    By nagpalma in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2007, 17:52
  3. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 14:27
  4. Replies: 4
    Last Post: 24th March 2006, 22:50
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.