Artificial Horizon like in Mission Planer
I need to make Artificial Horizon like in Mission Planer http://ardupilot.org/planner/docs/mission-planner-ground-control-station.html .
I have found some examples (Qwt and FlightInstruments) but there are oval widgets and I need rectangle.
May be somebody knows where I can get an example?
build your own :)
The Misson Planner Horizon Widget is nothing else than a rotating rectangle inside a bounding box (if you ignore the fancy stuff and some scales)
Pablo J. Rogina
there are oval widgets and I need rectangle.
Just put such widgets on top of a rectangle, and you're done with such requirement...
This type of widget design should be a formal Qt training exercise because it exposes the student to some fundamental concepts of custom paint events and using the QPainter, while creating something that many programmers will eventually want to see anyways.
@pl45m4 I need pitch too)))
I have a good experiences with Qt, but with console apps, whithout witgets.
Ok, I will try to build my own)))
const int width = size().width(); const int height = size().height(); const int halfwidth = width/2; const int halfheight = height/2; const qreal every5deg = -height / 60; const qreal pitchoffset = -pitch * every5deg; qreal pitch = -13.7; qreal roll = -10.1; QPainter painter(this); painter.save(); painter.translate(width/2, height/2); painter.rotate(-roll); qreal offset = 0.5 + pitchoffset / height / 2; if (offset < 0) offset = 0; else if (offset > 1) offset = 1; QLinearGradient linearGrad(0, -height, 0, height); linearGrad.setColorAt(0, Qt::cyan); linearGrad.setColorAt(offset > 0 ? offset-0.001 : offset, Qt::cyan); linearGrad.setColorAt(offset < 1 ? offset+0.001 : offset, QRgb(0x9bb824)); linearGrad.setColorAt(1, QRgb(0x414f07)); QRect rect(-width, -height, halfwidth * 4, halfheight * 4); painter.fillRect(rect, QBrush(linearGrad)); // just point at center painter.setBrush(Qt::red); painter.drawEllipse(0, 0, 20, 20); painter.restore();
Pablo J. Rogina
great! Is your issue solved? please don't forget to mark your post as such. Thanks