Results 1 to 4 of 4

Thread: mirror filping ???

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default mirror filping ???

    hell guys,

    If i draw a rect using painter ... how can mirror it using the the origin point. ????

    thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,679
    Thanks
    13
    Thanked 1,597 Times in 1,525 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: mirror filping ???

    QPainter::scale() with a negative scale factor works (if I understood your question):
    Qt Code:
    1. class Widget: public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. Widget(QWidget *p = 0): QWidget(p) {
    6. resize(640, 480);
    7. }
    8.  
    9. void paintEvent(QPaintEvent *event) {
    10. QRect r(50, 50, 200, 100);
    11.  
    12. // for a bit of colour
    13. QLinearGradient linearGradient(r.topRight(), r.bottomLeft());
    14. linearGradient.setColorAt(0.0, Qt::white);
    15. linearGradient.setColorAt(0.2, Qt::green);
    16. linearGradient.setColorAt(1.0, Qt::black);
    17.  
    18. QPainter p(this);
    19. p.translate(320, 0); // put x origin in centre
    20.  
    21. p.setBrush(linearGradient);
    22. p.drawRect(r);
    23.  
    24. p.setPen(Qt::red);
    25. p.scale(-1.0, 1.0);
    26. p.drawRect(r);
    27.  
    28. }
    29. };
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    jesse_mark (1st November 2012)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mirror filping ???

    Great this exactly what i mean.

    but now i faced other problem ... I have text along the rect sides (bottom and left) when i flip the text show flipped as well, is there a way where i can make the Text show correctly but still in the direction of the painter ?

    Thank you so much


    Added after 44 minutes:


    I tried to use

    p->setLayoutDirection(Qt::RightToLeft);

    but it didn't work, it didn't show any affect actually.
    Last edited by jesse_mark; 1st November 2012 at 16:25.

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

    Default Re: mirror filping ???

    You need to calculate where the text should go and then QPainter::translate() QPainter::drawText() it yourself.

Similar Threads

  1. Mirror nodes in QTreeView - reuse of QStandardItem fail
    By muenalan in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2011, 14:13
  2. Mirror Font
    By _Jack_ in forum Qt Programming
    Replies: 6
    Last Post: 15th May 2010, 18:49
  3. How to mirror-image text?
    By WinchellChung in forum Newbie
    Replies: 11
    Last Post: 31st July 2007, 18:13
  4. 4.3.0 installer and MinGW mirror problem
    By ucomesdag in forum Installation and Deployment
    Replies: 2
    Last Post: 8th July 2007, 04:17
  5. mirror for QGraphicsItem
    By jobrandt in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2007, 10:09

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.