Friday, July 4th 2008, 9:23pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

41

Saturday, April 12th 2008, 12:44pm

RE: QwtGrid Plot

just put a grid on the plot, it will be automatically moved
Nicolas
  • Go to the top of the page

crazycoder

Trainee

Posts: 128

Occupation: Software Engineer

42

Saturday, April 12th 2008, 5:03pm

RE: QwtGrid Plot

Hi Nicolas thank you for the reply. I tried this but i still have some errors.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void PlottingGraph::draw()
{
	m_time++;
	memmove(m_y, &m_y[1], 99 * sizeof(double));
	m_y[99] = 10000 * sin((double)m_time / 360 * 3.1415 * 10) + rand() % 4000 - 2000;//m_y[99] = 100 * sin((double)m_time / 360 * 3.1415 * 10) + rand() % 400 - 200;
	for (int i = 0; i < 100; i++)
            m_x[i]++;
	if (!m_curve)
	{      
        qreal left = int(rect.left()) - (int(rect.left()) % gridSize);
        qreal top = int(rect.top()) - (int(rect.top()) % gridSize);
        QVarLengthArray<QLineF, 100> lines;
        for (qreal x = left; x < rect.right(); x += gridSize)
        lines.append(QLineF(x, rect.top(), x, rect.bottom()));
        for (qreal y = top; y < rect.bottom(); y += gridSize)
        lines.append(QLineF(rect.left(), y, rect.right(), y));
        qDebug() << lines.size();
        painter->drawLines(lines.data(), lines.size());

		        m_curve = new QwtPlotCurve();
                m_curve->setPen(QPen(Qt::blue));//setPen(QPen(QColor::fromRgb(255, 255, 0), 3));
                m_curve->setData(m_x, m_y, 100);
		        m_curve->attach(myPlot);
	}
    m_curve->setData(m_x, m_y, 100);
    myPlot->setAxisScale(QwtPlot::xBottom, m_time, m_time + 100); // auto replots 
}


Hey pls tell me how i have use QwtGrid class in this program.

Thank You Nicolas
  • Go to the top of the page

crazycoder

Trainee

Posts: 128

Occupation: Software Engineer

43

Monday, May 5th 2008, 2:12pm

Horizontal Scroll Bar for Qwt Plot Widget

Hi Nicolas and Messenger. Thanks to you both i am working on qwt plot widget i got it working with VS2005. Now i am stuck with a problem. I need to have a Scroll Bar on the Qwt Plot widget at the Bottom axis. so that i can scroll back to any part to look at the graph. How can i implement this. I am plotting Real Time graphs at the referesh rate of 1 sec. The graphs keeps growing from Left to right. pls give me a small example code if you have.


Thank You
  • Go to the top of the page

44

Monday, May 5th 2008, 2:46pm

RE: Horizontal Scroll Bar for Qwt Plot Widget

Have a look at qwt event filter example

May be it's convenient
Nicolas
  • Go to the top of the page

crazycoder

Trainee

Posts: 128

Occupation: Software Engineer

45

Monday, May 5th 2008, 5:30pm

RE: Horizontal Scroll Bar for Qwt Plot Widget

Hey thankx for the reply i had a look at the Event Filter program. But it is a Qwt Wheel. I wanted a Horizontal Scroll and i sud be able to scroll back to any part of the Plot. Since it is a Real Time graph. How should i do this exactly. Should i save the Already Plotted Graph ? And how do i connect the Horizontal Scroll to the QwtPlot ?? So that when i scroll back the qwt plot screen moves to the position.?
  • Go to the top of the page

46

Monday, May 5th 2008, 5:49pm

RE: Horizontal Scroll Bar for Qwt Plot Widget

Get inspiration from the example,
replace QwtWheel with QScrollBar,
replace signals and slots with something convenient,
I didn't look, but probably those of QwtWheel have double arguments
and those of QScrollBar integer arguments
but you should abble to adapt to your needs
Nicolas
  • Go to the top of the page

crazycoder

Trainee

Posts: 128

Occupation: Software Engineer

47

Thursday, May 15th 2008, 11:52am

RE: QwtGrid Plot

hi messenger,

i need a small help from u..
can u explain me why this code when executed starts from 100...

is it mandatory that it need to start from 100 only...
i mean to ask u that can i have a custom option..
ie. as of now it is running from 100 in my code i need it to run from 0.. with a time difference of 2 mill sec or 5 mill sec.. so where should i change that...

and one more thing i forgot to ask
what exactly is happening in this sine equation...

m_y[99] = 20 * sin((double)m_time / 360 * 3.1415 * 10) + rand() % 40 - 20;
what value is there in m_y[99]

can u please explain me...

thanks in advance...

This post has been edited 1 times, last edit by "crazycoder" (May 15th 2008, 11:59am)

  • Go to the top of the page

Rate this thread