Results 1 to 13 of 13

Thread: Draw rectangle on QImage

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Draw rectangle on QImage

    Please provide some minmal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    70
    Thanked 59 Times in 57 Posts

    Default Re: Draw rectangle on QImage

    Hi,

    I've tried this code in the constructor of a simple program.
    Qt Code:
    1. QImage qImage("a.bmp");
    2. QPainter qPainter(&qImage);
    3. qPainter.setBrush(Qt::NoBrush);
    4. qPainter.setPen(Qt::red);
    5. qPainter.drawRect(150,150,50,50);
    6. bool bEnd = qPainter.end();
    7. qImage.save("b.bmp");
    To copy to clipboard, switch view to plain text mode 

    With this I'll get the image "b.bmp" that is the same as "a.bmp" but with a red rectangle painted on position (150px,150px) with a widht and height of 50px.
    This don't work as "b.bmp" is identical as "a.bmp"

    Thanks,
    Òscar Llarch i Galán

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Draw rectangle on QImage

    What is the format of the BMP image? Is it 8b (indexed) or 24b (true color)?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 9th November 2012, 17:16
  2. Replies: 2
    Last Post: 4th May 2012, 10:10
  3. How to draw a QPainter rectangle over Widgets
    By sureshdharmadurai in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2011, 10:17
  4. How to draw rectangle with moveable edge
    By sagirahmed in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2010, 06:21
  5. how to draw columns in QPainter's rectangle
    By jyoti in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2007, 10:50

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
  •  
Qt is a trademark of The Qt Company.