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?
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.
Have a look at QGraphicsView and QGraphicsScene. Using QGraphicsRectItem you should be able to draw a bar plot with a few lines of code...
...or if the drawings are simple, just use a QWidget and do custom painting in QWidget::paintEvent()
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:
{ } { painter.setPen(Qt::NoPen); painter.drawLine(100, 100, 75, 225); painter.setBrush(Qt::VerPattern); painter.drawRect(100, 100, 600,200); }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 22nd June 2009 at 08:37. Reason: missing [code] tags
You have NoPen setting.. change to:
Qt Code:
{ pen.setColor( Qt::black ); painter.setPen( pen ); painter.drawLine(100, 100, 75, 225); painter.setBrush(Qt::VerPattern); painter.drawRect(100, 100, 600,200); }To copy to clipboard, switch view to plain text mode
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?
Last edited by maider; 22nd June 2009 at 09:42.
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.
Bookmarks