Results 1 to 8 of 8

Thread: Pixmap conversion

  1. #1
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Unhappy Pixmap conversion

    Hello Everyone........................
    I wana convert a constant string into a pixmap .................
    but I have no idea how will it happen????????
    if anyone can help me ? I'll very thankful to him

    Thanx

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap conversion

    I wana convert a constant string into a pixmap .................
    Can you elaborate ?

    Are you trying to save the contents of a textbox/textedit as pixmap ?? If yes, you may have a look at QWidget::render

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap conversion

    Use this
    Qt Code:
    1. QPixmap myPix(100, 100);
    2. QPainter painter;
    3. painter.begin(&myPix);
    4. painter.drawText(myPix.rect(), Qt::AlignHCenter | Qt::AlignVCenter, "Hello to All");
    5. painter.end();
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  4. #4
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Thumbs up Re: Pixmap conversion

    Thanx a lot mcosta........
    I m very thankful to you...........you solved my problem
    but again I need your help as u suggested I used that code in my program but problem is there how can we set the font size and font colour in that pixmap?????????
    I m waiting your reply................

  5. #5
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap conversion

    Add the "// NEW LINE" section to previous posted code

    Qt Code:
    1. QPixmap myPix(100, 100);
    2. QPainter painter;
    3. painter.begin(&myPix);
    4.  
    5. // NEW LINES: START
    6. painter.setPen(Qt::yellow); // set Color to yellow
    7. painter.setFont(QFont("Times", 16, QFont::Bold));
    8. // NEW LINES: STOP
    9.  
    10. painter.drawText(myPix.rect(), Qt::AlignHCenter | Qt::AlignVCenter, "Hello to All");
    11. painter.end();
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  6. #6
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Thumbs up Re: Pixmap conversion

    thanx, you are really great ..............
    you solved my problem......thanx aonce again...........

    But mcosta ,there is again a little problem is arising....i.e the pixmap does not contain whole string and how the set the background colour of this pixmap..................???

  7. #7
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap conversion

    You can use QPainter::fillRect()
    Qt Code:
    1. ....
    2. painter.fillRect(myPix.rect(), QBrush(myColor));
    3. painter.drawText(....);
    4. ....
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  8. #8
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Talking Re: Pixmap conversion

    Thank you so much .......................
    Now I have not any problem.................................

Similar Threads

  1. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  2. QWizard and banner pixmap
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 7th January 2008, 10:28
  3. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15
  4. Invalid pixmap
    By munna in forum Newbie
    Replies: 2
    Last Post: 8th June 2006, 08:00
  5. Paint XP radio button to pixmap
    By Ben.Hines in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2006, 21:15

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.