Пример #1
0
/*!
  \brief Constructor
  \param parent Parent widget
  \param name Widget name

  Create a compass widget with a scale, no needle and no rose. 
  The default origin is 270.0 with no valid value. It accepts
  mouse and keyboard inputs and has no step size. The default mode
  is QwtDial::RotateNeedle.
*/  
QwtCompass::QwtCompass(QWidget* parent, const char* name):
        QwtDial(parent, name),
    d_rose(0)
{
    setScaleOptions(ScaleLabel); // Only labels, no backbone, no ticks

    setOrigin(270.0);
    setWrapping(TRUE);


    d_labelMap.insert(0.0, QString::fromLatin1("N"));
    d_labelMap.insert(45.0, QString::fromLatin1("NE"));
    d_labelMap.insert(90.0, QString::fromLatin1("E"));
    d_labelMap.insert(135.0, QString::fromLatin1("SE"));
    d_labelMap.insert(180.0, QString::fromLatin1("S"));
    d_labelMap.insert(225.0, QString::fromLatin1("SW"));
    d_labelMap.insert(270.0, QString::fromLatin1("W"));
    d_labelMap.insert(315.0, QString::fromLatin1("NW"));

#if 0
    d_labelMap.insert(22.5, QString::fromLatin1("NNE"));
    d_labelMap.insert(67.5, QString::fromLatin1("NEE"));
    d_labelMap.insert(112.5, QString::fromLatin1("SEE"));
    d_labelMap.insert(157.5, QString::fromLatin1("SSE"));
    d_labelMap.insert(202.5, QString::fromLatin1("SSW"));
    d_labelMap.insert(247.5, QString::fromLatin1("SWW"));
    d_labelMap.insert(292.5, QString::fromLatin1("NWW"));
    d_labelMap.insert(337.5, QString::fromLatin1("NNW"));
#endif
}
Пример #2
0
void QwtCompass::initCompass()
{
    d_data = new PrivateData;

    setScaleOptions(ScaleLabel); // Only labels, no backbone, no ticks

    setOrigin(270.0);
    setWrapping(true);


    d_data->labelMap.insert(0.0, QString::fromLatin1("N"));
    d_data->labelMap.insert(45.0, QString::fromLatin1("NE"));
    d_data->labelMap.insert(90.0, QString::fromLatin1("E"));
    d_data->labelMap.insert(135.0, QString::fromLatin1("SE"));
    d_data->labelMap.insert(180.0, QString::fromLatin1("S"));
    d_data->labelMap.insert(225.0, QString::fromLatin1("SW"));
    d_data->labelMap.insert(270.0, QString::fromLatin1("W"));
    d_data->labelMap.insert(315.0, QString::fromLatin1("NW"));

#if 0
    d_data->labelMap.insert(22.5, QString::fromLatin1("NNE"));
    d_data->labelMap.insert(67.5, QString::fromLatin1("NEE"));
    d_data->labelMap.insert(112.5, QString::fromLatin1("SEE"));
    d_data->labelMap.insert(157.5, QString::fromLatin1("SSE"));
    d_data->labelMap.insert(202.5, QString::fromLatin1("SSW"));
    d_data->labelMap.insert(247.5, QString::fromLatin1("SWW"));
    d_data->labelMap.insert(292.5, QString::fromLatin1("NWW"));
    d_data->labelMap.insert(337.5, QString::fromLatin1("NNW"));
#endif
}
SpeedoMeter::SpeedoMeter(QWidget *parent):
    QwtDial(parent),
    d_label("km/h")
{
    setWrapping(false);
    setReadOnly(true);

    setOrigin(135.0);
    setScaleArc(0.0, 270.0);
    scaleDraw()->setSpacing(8);

    QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(
            QwtDialSimpleNeedle::Arrow, true, Qt::red, 
            QColor(Qt::gray).light(130));
    setNeedle(needle);

    setScaleOptions(ScaleTicks | ScaleLabel);
    setScaleTicks(0, 4, 8);
}