int SortingBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: createNewCircle(); break;
        case 1: createNewSquare(); break;
        case 2: createNewTriangle(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Beispiel #2
0
//! [0]
SortingBox::SortingBox()
{
//! [0] //! [1]
    setMouseTracking(true);
//! [1] //! [2]
    setBackgroundRole(QPalette::Base);
//! [2]

    itemInMotion = 0;

//! [3]
    newCircleButton = createToolButton(tr("New Circle"),
                                       QIcon(":/images/circle.png"),
                                       SLOT(createNewCircle()));

    newSquareButton = createToolButton(tr("New Square"),
                                       QIcon(":/images/square.png"),
                                       SLOT(createNewSquare()));

    newTriangleButton = createToolButton(tr("New Triangle"),
                                         QIcon(":/images/triangle.png"),
                                         SLOT(createNewTriangle()));

    circlePath.addEllipse(QRect(0, 0, 100, 100));
    squarePath.addRect(QRect(0, 0, 100, 100));

    qreal x = trianglePath.currentPosition().x();
    qreal y = trianglePath.currentPosition().y();
    trianglePath.moveTo(x + 120 / 2, y);
    trianglePath.lineTo(0, 100);
    trianglePath.lineTo(120, 100);
    trianglePath.lineTo(x + 120 / 2, y);

//! [3] //! [4]
    setWindowTitle(tr("Tool Tips"));
    resize(500, 300);

    createShapeItem(circlePath, tr("Circle"), initialItemPosition(circlePath),
                    initialItemColor());
    createShapeItem(squarePath, tr("Square"), initialItemPosition(squarePath),
                    initialItemColor());
    createShapeItem(trianglePath, tr("Triangle"),
                    initialItemPosition(trianglePath), initialItemColor());
}
//=============================================================================
sstQt01PathPaintWidgetCls::sstQt01PathPaintWidgetCls(sstMisc01PrtFilCls      *poTmpPrt,
                                                     sstQt01PathStoreViewCls *poTmpPathStorage)
{

  Q_INIT_RESOURCE(tooltips);

  if (poTmpPathStorage == NULL) assert (0);
  if (poTmpPathStorage->countItems() <= 0) assert(0);

  this->oPathStorage = poTmpPathStorage;
  this->poPrt = poTmpPrt;

  setMouseTracking(true);
    setBackgroundRole(QPalette::Base);

    newCircleButton = createToolButton(tr("New Circle"),
                                       QIcon(":/images/circle.png"),
                                       SLOT(createNewCircle()));

    newSquareButton = createToolButton(tr("New Square"),
                                       QIcon(":/images/square.png"),
                                       SLOT(createNewSquare()));

    newTriangleButton = createToolButton(tr("New Triangle"),
                                         QIcon(":/images/triangle.png"),
                                         SLOT(createNewTriangle()));

    newLineButton = createToolButton(tr("New Line"),
                                         QIcon(":/images/line.png"),
                                         SLOT(createNewLine()));

    newPolyLineButton = createToolButton(tr("New PolyLine"),
                                         QIcon(":/images/polyline.png"),
                                         SLOT(createNewPolyLine()));

    newArcButton = createToolButton(tr("New Arc"),
                                         QIcon(":/images/arc.png"),
                                         SLOT(createNewArc()));

    newTextButton = createToolButton(tr("New Text"),
                                         QIcon(":/images/text.png"),
                                         SLOT(createNewText()));

    //=============================================================================
    // Create item templates
    circlePath.addEllipse(QRect(0, 0, 100, 100));
    squarePath.addRect(QRect(0, 0, 100, 100));

    qreal x = trianglePath.currentPosition().x();
    qreal y = trianglePath.currentPosition().y();
    trianglePath.moveTo(x + 120 / 2, y);
    trianglePath.lineTo(0, 100);
    trianglePath.lineTo(120, 100);
    trianglePath.lineTo(x + 120 / 2, y);

    linePath.moveTo( 0, 0);
    linePath.lineTo(100, 100);

    polylinePath.moveTo( 0, 0);
    polylinePath.lineTo(25, 75);
    polylinePath.lineTo(100, 100);

    // arcPath.moveTo( 150, 150);
    QRect oRect(100,100,200,200);
    arcPath.arcMoveTo(oRect,0);
    arcPath.arcTo(oRect,0,45);

    QFont oFont;
    oFont.setPointSize(50);
    // oFont.s
    QString oQStr = "A";
    textPath.moveTo( 0, 0);
    textPath.addText(50,50,oFont,oQStr);
    //=============================================================================

    setWindowTitle(tr("Tool Tips"));
    this->setMinimumSize(350,350);  // Get Size for 7 Buttons

    iActualItemIndex = 0;
    iItemInMotionIndex = 0;

}