Results 1 to 2 of 2

Thread: set a line with and a color?

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: set a line with and a color?

    Hi,

    I'm having a simple problem but I can't seem to find the answer.
    I want to set my plot's width and color. I can set one or the other using QPen but I can't figure out how to set them both! If I try to set them both separately the first one is overwritten by the second. What am I missing?

    Qt Code:
    1. QwtPlotCurve * curve;
    2.  
    3. curve->setPen(QPen(Qt::red));
    4.  
    5. QPen pen;
    6. pen.setWidth(3);
    7.  
    8. curve->setPen(pen);
    To copy to clipboard, switch view to plain text mode 

    thanks

    Oh Wow, nevermind, I'm stupid

    Qt Code:
    1. QPen pen;
    2. pen.setWidth(lineWidth);
    3. pen.setColor(Qt::blue);
    4. curve->setPen(pen);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: set a line with and a color?

    a littel bit shorter:
    Qt Code:
    1. curve->SetPen(QPen(Color(Qt::red),lineWidth)))
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to FelixB for this useful post:

    kja (3rd December 2010)

Similar Threads

  1. Draw line with inverted background color
    By viswanath in forum Qt Programming
    Replies: 4
    Last Post: 12th November 2011, 03:57
  2. Replies: 3
    Last Post: 13th August 2010, 11:50
  3. Image reading and writing line by line
    By Astrologer in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2010, 08:15
  4. QListView Line Color
    By fruzzo in forum Qt Programming
    Replies: 1
    Last Post: 9th May 2008, 09:42
  5. Slot to color background of line edit on textedited
    By tpf80 in forum Qt Programming
    Replies: 5
    Last Post: 21st June 2007, 09: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.