QtCanvasItem *MainWindow::addEllipse() { QtCanvasPolygonalItem *item = new QtCanvasEllipse(50, 50, canvas); item->setBrush(QColor(rand() % 32 * 8, rand() % 32 * 8, rand() % 32 * 8)); item->move(rand() % canvas->width(), rand() % canvas->height()); item->setZ(rand() % 256); item->show(); return item; }
QtCanvasItem *MainWindow::addRectangle() { QtCanvasPolygonalItem *item = new QtCanvasRectangle(rand() % canvas->width(), rand() % canvas->height(), 50, 50, canvas); int z = rand() % 256; item->setBrush(QColor(rand() % 32 * 8, rand() % 32 * 8, rand() % 32 * 8)); item->setPen(QPen(QColor(rand() % 32*8, rand() % 32*8, rand() % 32*8), 4)); item->setZ(z); item->show(); return item; }