user
19th July 2007, 07:22
Hello,
This is my first post so I hope I give all the required info.
I use Qt 4.2.3 and Qwt 5.0.1
I'm trying to create a compass or a dial that will show wind direction.
I created a class that inherits QwtCompass and in it's constructor:
windNeedle = new QwtCompassWindArrow( Style1, red, black );
rose = new QwtSimpleCompassRose( 4, 1 );
I instanciate this class in a layout which is inside a QWidget. So the compass is only part of what is displayed on the screen.
I have 2 problems:
1. I would like to change the size and direction of the windNeedle. The function I found is drawStyle1Needle(...) or draw() which calls that function.
When I try to use that function in the constructor I get the error: QPainter::begin: Widget painting can only begin as a result of a paintEvent.
What is the right way to use those functions? How do I create the paintEvent and how and when do I use the draw() function?
2. I would also like to change the direction of the windNeedle (since it represents wind direction and it may change) - How do I get the value after the user moved the needle and how do I set the needle to a certain direction? - I guess the setting part would require redrawing of the compass which is my first problem.
This is my first post so I hope I give all the required info.
I use Qt 4.2.3 and Qwt 5.0.1
I'm trying to create a compass or a dial that will show wind direction.
I created a class that inherits QwtCompass and in it's constructor:
windNeedle = new QwtCompassWindArrow( Style1, red, black );
rose = new QwtSimpleCompassRose( 4, 1 );
I instanciate this class in a layout which is inside a QWidget. So the compass is only part of what is displayed on the screen.
I have 2 problems:
1. I would like to change the size and direction of the windNeedle. The function I found is drawStyle1Needle(...) or draw() which calls that function.
When I try to use that function in the constructor I get the error: QPainter::begin: Widget painting can only begin as a result of a paintEvent.
What is the right way to use those functions? How do I create the paintEvent and how and when do I use the draw() function?
2. I would also like to change the direction of the windNeedle (since it represents wind direction and it may change) - How do I get the value after the user moved the needle and how do I set the needle to a certain direction? - I guess the setting part would require redrawing of the compass which is my first problem.