Results 1 to 9 of 9

Thread: painting lines on the screen

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

    Default painting lines on the screen

    After trying many things and failed, i finally came here to do what i was trying.
    I want to display lines which are stored in a file named "line.txt" in comma seperated values.
    i have successfully read the values, but unable to draw them on the screen.
    please help.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: painting lines on the screen

    QGraphicsLineItem can be used to create a line and then add it to a QGraphicsScene, and set that QGraphicsScene on to a QGraphicsView
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    Default Re: painting lines on the screen

    @santosh reddy:
    do i have to reimplement the paintEvent method to use this?
    If possible give an example code for this.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: painting lines on the screen

    No, QWidget::paintEvent() is not involved in what Santosh Reddy proposed as one solution to your vague requirement.

    If you read the docs of the classes Santosh pointed out you'll find there are detailed descriptions of each class and links to the Graphics View Framework overview containing code snippets and whole examples/demos.

    After "trying many things and failed" you should be able to better explain what you need, show what you tried, and explain why it does not meet your requirement.
    Last edited by ChrisW67; 10th February 2013 at 04:00.

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

    Default Re: painting lines on the screen

    Ok , i tried again and succeeded this time.
    method used:
    read all the lines from the file into a qvector<qline> and used qpainter::drawlines() to draw the lines all at a time.

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

    Default Re: painting lines on the screen

    Quote Originally Posted by neutrino View Post
    Ok , i tried again and succeeded this time.
    method used:
    read all the lines from the file into a qvector<qline> and used qpainter::drawlines() to draw the lines all at a time.
    Just being curious --- so what have you tried "before" when you failed?
    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.


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

    Default Re: painting lines on the screen

    i was trying to implement the functions described in the example "scribble" without understanding. Was doing random methods and hoping that something would work. now got another method to do the same(by using qimage for drawing widgets, and drawing the image via qpainter).
    how to mark this thread as solved?
    another question: is there any way to remove a line from the qimage other than drawing a line of the same color as the background.

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

    Default Re: painting lines on the screen

    Quote Originally Posted by neutrino View Post
    another question: is there any way to remove a line from the qimage other than drawing a line of the same color as the background.
    No, an image is an image -- a set of pixels with defined color values. It has no "history".
    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.


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

    Default Re: painting lines on the screen

    ok. thanks

Similar Threads

  1. Replies: 0
    Last Post: 16th February 2011, 23:29
  2. Replies: 1
    Last Post: 29th June 2010, 17:59
  3. Problem painting lines
    By jano_alex_es in forum Newbie
    Replies: 9
    Last Post: 29th June 2009, 19:31
  4. Painting on screen
    By Alex_123 in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2009, 19:00
  5. Painting lines
    By therealjag in forum Newbie
    Replies: 34
    Last Post: 23rd March 2006, 22:43

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.