Results 1 to 10 of 10

Thread: create image with specific size

  1. #1
    Join Date
    Aug 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default create image with specific size

    I want to create an image that I want to print. I wil make this image from line edits that have been entered in by the user. Now what class do I use to make an image with a specific size. The image I want to print must have a size of 10 cm by 20 cm. So I should be able to give it this size for printing, and I should also be able to say what size the line edits are put on the image. Anyone can help?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: create image with specific size

    Use QImage or QPixmap.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: create image with specific size

    Ok, and lets say I want text at like lets say 2 cm to the right and 1 cm down on the page (so at (2cm, 1cm), how to say I want it right there?
    And after I'm finished, how to I say to the QPrinter that I want the QPixmap to be printed as 10cm x 20cm?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: create image with specific size

    Quote Originally Posted by Origin View Post
    Ok, and lets say I want text at like lets say 2 cm to the right and 1 cm down on the page (so at (2cm, 1cm), how to say I want it right there?
    You have to calculate these dimensions according to a printer's settings.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Aug 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: create image with specific size

    Quote Originally Posted by spirit View Post
    You have to calculate these dimensions according to a printer's settings.
    Hmm ok, but lets presume the printer settings are that the paper size is 10cm x 20cm, if I then take a QPixmap, and get the width and height: If i want to place something at 1 cm to 2cm on the real printed paper, will dividing the width of the QPixmap by 10 and the height by 10 be the QPoint position to put the text at the place I want it?

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: create image with specific size

    You need also know a printer's dpi for converting pixels to cm. Then you can properly calculate an image width, height and a text position.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Aug 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: create image with specific size

    Quote Originally Posted by spirit View Post
    You need also know a printer's dpi for converting pixels to cm. Then you can properly calculate an image width, height and a text position.
    Hmm, that sounds really weird, because that means that when I have 2 printers, making a document and printing it on one printer and then on the other could give an entire different output? There is no way around this? Making it generic?

  8. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: create image with specific size

    Qt is not printing lib. It has only basic functionality for this.
    Actually, all what you need it's to write a function which converts pixels to cm and then use it before rendering (printing).
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  9. #9
    Join Date
    Aug 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: create image with specific size

    Oké, so you mean do the conversion right before printing? That could work thanks .

  10. #10
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: create image with specific size

    Quote Originally Posted by Origin View Post
    Oké, so you mean do the conversion right before printing?
    Yup, exactly.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Replies: 2
    Last Post: 4th April 2012, 00:53
  2. Does QVGImagePool has specific size?
    By SlaynX in forum Newbie
    Replies: 0
    Last Post: 1st July 2011, 19:48
  3. Qt Designer Platform specific font size for labels
    By abey in forum Qt Tools
    Replies: 0
    Last Post: 16th February 2011, 17:21
  4. Replies: 1
    Last Post: 10th March 2010, 11:12
  5. Replies: 1
    Last Post: 24th October 2006, 17:40

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.