Results 1 to 3 of 3

Thread: drawing lines using qpainter from file

  1. #1
    Join Date
    Jul 2011
    Location
    Kolkata,India
    Posts
    18
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default drawing lines using qpainter from file

    I'm new to Qt programming and trying to build a gui program for a project. I need to draw multiple lines on the widget. The dimensions of the lines are stored in a file "line.txt". The file is correctly read by using qfile and qtextstream. I have also implemented the paintEvent() to draw one line. But when i'm trying to draw multiple lines, it shows no output. What's the problem and how to correct it? i'm attaching the code and the file "line.txt"
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: drawing lines using qpainter from file

    In future post, please post the relevant lines direct in the thread.

    a) don't read the file every time paintEvent is called - which is quite often. Use the constructor and parse the file in a QList<QLine> or something similar.
    b) Never call update or paint inside paintEvent!

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

    Default Re: drawing lines using qpainter from file

    There is this nice thing in Qt called QPicture, have a look at it.
    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. Drawing row/column lines in QTreeWidget
    By warvimo in forum Newbie
    Replies: 0
    Last Post: 25th May 2012, 17:33
  2. QPainter::drawLine(): straight lines look aliased
    By xqrp in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2012, 13:18
  3. Combining QPainter and WinAPI drawing
    By kkk777kkk in forum Newbie
    Replies: 2
    Last Post: 6th July 2011, 14:16
  4. Text drawing with QPainter
    By Rambobino in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2010, 17:26
  5. use Qpainter to draw lines + problem in my painter
    By ReSu in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2008, 15:44

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.