Results 1 to 2 of 2

Thread: QTextEdit does not show!!!!

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question QTextEdit does not show!!!!

    Hi again to all!

    I have a code:
    Qt Code:
    1. void CMerchandizeBrowser::paintEvent(QPaintEvent* event)
    2. {
    3. Q_UNUSED(event);
    4. QPainter painter(this);
    5. painter.setRenderHint(QPainter::Antialiasing, false);
    6. painter.drawImage(QPoint(0,0), d->buffer);
    7.  
    8. // shows merchandize info: name, price, descriptions
    9. painter.setPen(Qt::white); // sets white pen's color
    10. painter.setBrush(Qt::NoBrush); // sets brush
    11. //p.drawRect(merchandizeDescriptionRect);
    12. painter.setFont(QFont("Arial", 12)); // sets test font
    13. QFontMetrics fm(painter.font()); // sets up font metrcis
    14. QRectF computedRec(merchandizeDescriptionRect);
    15. /*
    16.   painter.drawText(computedRec, Qt::AlignLeft, getMerchandizeName(m_ImagesList.at(m_iSelected).text(strKeyImagePathName)));
    17. */
    18. painter.drawText(computedRec, Qt::AlignLeft, getMerchandizeName(d->slideImages.at(currentSlide()).text(strKeyImagePathName)));
    19. // appends "euro" sing at the end of the price
    20. QString priceString(getMerchandizePrice(d->slideImages.at(currentSlide()).text(strKeyImagePathName)));
    21. priceString=priceString.append(" EUR");
    22. painter.drawText(computedRec, Qt::AlignRight, priceString);
    23. // shows merchandize description
    24. QTextEdit merchandizeDescription(getMerchandizeDescription((qint16)currentSlide()), this); // new instance of qtextedit
    25. merchandizeDescription.show(); // shows constucted text
    26. }
    To copy to clipboard, switch view to plain text mode 
    And QTextEdit is not shown? Can someone help me out, please?
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit does not show!!!!

    You create QTextEdit on the stack and it immediately goes out of scope, so you don't have a chance to see it. Also paintEvent() isn't the best place to create widgets.

Similar Threads

  1. Display a file from Directory tree to show in QTextEdit
    By vvdounai in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 13:43
  2. QTextEdit & background colors
    By marziac in forum Qt Programming
    Replies: 4
    Last Post: 24th August 2007, 12:52
  3. QTextEdit: I can not see the cursor by deafult
    By sukanyarn in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 07:55
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  5. Painting to QTextEdit
    By gesslar in forum Qt Programming
    Replies: 8
    Last Post: 18th February 2006, 18: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.