Results 1 to 3 of 3

Thread: QGraphicsView - problems when scrolling text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default QGraphicsView - problems when scrolling text

    Hi

    I am having problems displaying a text string in the top left hand corner of my QGraphicsView widget. When scrolling the text scrolls as well, I would like the text to stay in position at the top left hand corner of the widget.

    UpdateDisplay is called when an image is ready for display, this forces the paint event for the QGraphicsView

    My code is below, what am I doing wrong?

    Qt Code:
    1. void CScanWin::paintEvent(QPaintEvent *event)
    2. {
    3. QGraphicsView::paintEvent(event); //pass the event to the graphic view ???
    4.  
    5. QString status = "All Sources available..." + QString::number(q);
    6. QPainter painter(viewport());
    7. painter.setPen(QColor(Qt::yellow));
    8. painter.drawText(10, 10, status);
    9.  
    10. }
    11.  
    12. o
    13. void CScanWin::UpdateDisplay()
    14. {
    15. q++;
    16. cscanScene->clear();
    17. cscanScene->setSceneRect(img->rect());
    18. cscanScene->addPixmap(QPixmap::fromImage(*img));
    19. viewport()->update();
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    Last edited by mlik; 13th May 2010 at 13:21. Reason: updated contents

Similar Threads

  1. QGraphicsView and Scrolling
    By validator in forum Qt Programming
    Replies: 5
    Last Post: 8th September 2017, 00:27
  2. QGraphicsWidget disappear when scrolling QGraphicsView
    By T4ng10r in forum Qt Programming
    Replies: 10
    Last Post: 21st January 2010, 13:24
  3. Custom scrolling of QGraphicsView
    By hb in forum Qt Programming
    Replies: 0
    Last Post: 12th August 2008, 10:10
  4. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18
  5. Replies: 3
    Last Post: 20th February 2007, 13:02

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.