Results 1 to 7 of 7

Thread: Graphics without qwt

  1. #1
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Graphics without qwt

    I want do a graphic that plot some bars or rects into two axys, x and y.

    I can not use qwt due to I have to do everything step by step.

    Does anyone can help me?
    Last edited by maider; 17th June 2009 at 14:44.

  2. #2
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics without qwt

    Have a look at QGraphicsView and QGraphicsScene. Using QGraphicsRectItem you should be able to draw a bar plot with a few lines of code...

  3. #3
    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: Graphics without qwt

    ...or if the drawings are simple, just use a QWidget and do custom painting in QWidget::paintEvent()

  4. #4
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Graphics without qwt

    I have get the lines, but how can I do the axes?i have tryed doing with drawLine() but they don't see.The code of the lines is the following one:
    Qt Code:
    1. Brush::Brush(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4.  
    5. }
    6.  
    7. void Brush::paintEvent(QPaintEvent *event)
    8. {
    9. QPainter painter(this);
    10. painter.setPen(Qt::NoPen);
    11.  
    12. QPen pen(Qt::black,2);
    13. painter.drawLine(100, 100, 75, 225);
    14. painter.setBrush(Qt::VerPattern);
    15. painter.drawRect(100, 100, 600,200);
    16.  
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 22nd June 2009 at 08:37. Reason: missing [code] tags

  5. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphics without qwt

    You have NoPen setting.. change to:

    Qt Code:
    1. void Brush::paintEvent(QPaintEvent *event)
    2. {
    3. QPainter painter(this);
    4.  
    5. QPen pen = painter.pen();
    6. pen.setColor( Qt::black );
    7.  
    8. painter.setPen( pen );
    9.  
    10. painter.drawLine(100, 100, 75, 225);
    11. painter.setBrush(Qt::VerPattern);
    12. painter.drawRect(100, 100, 600,200);
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Graphics without qwt

    I have done as you tell me but the shape that it is drawn is not what I need.
    I need to paint the "axe t" and the "axe y" that I have added to the picture.
    how can I do the axes?
    Attached Files Attached Files
    Last edited by maider; 22nd June 2009 at 09:42.

  7. #7
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Graphics

    what I am doing wrong?

    I'm trying with QGraphicsLineItem but i don't get it!

    My new code is:

    Brush::Brush(QWidget *parent)
    : QWidget(parent)
    {

    }

    void Brush:aintEvent(QPaintEvent *event)
    {
    QGraphicsScene *scene1 = new QGraphicsScene(this);
    int x1, y1, x2, y2, t;
    x1 = 0; y1=0; x2=100; y2=2, t=0;

    QPainter painter(this);
    painter.setPen(Qt::NoPen);

    QPen pen(Qt::black,2);
    painter.drawLine(100, 100, 75, 225);
    painter.setBrush(Qt::VerPattern);
    painter.drawRect(100, 100, 600,200);


    QGraphicsLineItem *line = new QGraphicsLineItem( QLineF( x1,y1, x2, y2 ) );
    scene1->addItem(line);
    Last edited by maider; 22nd June 2009 at 13:16.

Similar Threads

  1. qwt 5.2 install on qt 4.5
    By HyperB in forum Qwt
    Replies: 4
    Last Post: 13th May 2009, 20:03
  2. Step by step Qwt on MinGW
    By Doug Broadwell in forum Qwt
    Replies: 2
    Last Post: 23rd January 2009, 00:19
  3. QWT introduction
    By nitriles in forum Qwt
    Replies: 4
    Last Post: 28th September 2007, 10:48
  4. How to upgrade Qwt 5.0.1 to Qwt 5.0.2
    By luffy27 in forum Qwt
    Replies: 1
    Last Post: 15th July 2007, 19:55
  5. use interesting QWT Library with QT3.X
    By raphaelf in forum Qwt
    Replies: 2
    Last Post: 23rd January 2006, 11:24

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.