QGraphicViewDm::QGraphicViewDm(QWidget *parent) : QGraphicsView(parent) { int iWidth , iHeight ; // iWidth = width( ); // iHeight = height( ); iWidth = 600 ; iHeight = 230 ; QGraphicsScene *scene = new QGraphicsScene(this); scene->setSceneRect(-iWidth/2,-iHeight/2,iWidth,iHeight); setScene(scene); setCacheMode(CacheBackground); //加一个矩形 QRectF r = QRectF(-iWidth/2,-iHeight/2,iWidth,iHeight); // qDebug( ) << r.topLeft() << r.bottomRight() ; QRectF r1 = r.adjusted( 20, 20, -20, -20 ); // qDebug( ) << r1.topLeft() << r1.bottomRight() ; QGraphicsRectItem * pRect = scene->addRect( r1 ); //创建用的是对象座标 pRect->setPos( 0, 0 ); //给的是场景座标 pItemDm = new ItemDm ; // 4/5 的宽度 2/3的高度 float fAdjust1, fAdjust2 ; fAdjust1 = 1.0 / 10.0 * iWidth ; fAdjust2 = 1.0 / 6.0 * iHeight ; // qDebug( ) << fAdjust1 << fAdjust2 << r.adjusted( fAdjust1 , fAdjust2, -1*fAdjust1, -1*fAdjust2 ) ; pItemDm->init( r.adjusted( fAdjust1 , fAdjust2, -1*fAdjust1, -1*fAdjust2 ) ); pItemDm->setWater( 1250.00 ); scene->addItem( pItemDm ); pItemDm->setPos( 0, 0 ); //制作 QRectF rectFish( 0, 0, 15, 5 ); pFish = scene->addEllipse( rectFish ); pFish->setPos( 0, 0 ); //pFish->setBrush( QBrush(Qt::red) ); pFish->setBrush( QBrush(Qt::green) ); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsScene s; QGraphicsView v(&s); ChangingBackground background(256,256); s.addItem(&background); std::vector<boost::shared_ptr<TransparentSprite> > sprites; //Add multiple sprites { const double pi = boost::math::constants::pi<double>(); const int n_sprites = 10; const double midx = background.pixmap().width() / 2.0; const double midy = background.pixmap().height() / 2.0; const double ray = std::min(midx,midy) * 0.8; const double d_angle = 2.0 * pi / static_cast<double>(n_sprites); double angle = 0.0; for (int i=0; i!=n_sprites; ++i) { boost::shared_ptr<TransparentSprite> sprite( new TransparentSprite( 32, 32, 128 + (std::rand() % 128), 128 + (std::rand() % 128), 128 + (std::rand() % 128) ) ); const double x = midx + (std::sin(angle) * ray) - (sprite->pixmap().width() / 2); const double y = midy - (std::cos(angle) * ray) - (sprite->pixmap().height() / 2); sprite->setX(x); sprite->setY(y); sprite->setRect(background.pixmap().width(),background.pixmap().height()); s.addItem(sprite.get()); sprites.push_back(sprite); angle+=d_angle; } } v.show(); boost::shared_ptr<QTimer> timer(new QTimer(&s)); timer->connect(timer.get(), SIGNAL(timeout()), &s, SLOT(advance())); timer->start(50); return a.exec(); }
void MainWindow::openFile(const QString& fileName) { QApplication::setOverrideCursor(Qt::WaitCursor); _timeBar->stopClicked(); QFileInfo fileInfo(fileName); ReaderWriterILDA reader; _lastDirectory = fileInfo.absoluteFilePath(); _sequence = reader.readFile(fileName); _sequence->setPalette(*_currentPalette); // Fill file statistics fileNameLabel->setText(fileInfo.fileName()); fileSizeLabel->setText(getFileSize(fileInfo.size())); ildaFormatLabel->setText(reader.version()); numberOfFramesLabel->setText(QString::number(_sequence->frameCount())); // Set the current drawing mode (FIXME: Do not query the GUI for such infos) drawModeChanged(); // Setup timeline _timeBar->setRange(0, _sequence->frameCount() / 1000.0 * 30); _timeLine = _timeBar->timeLine(); _timeLine->setDuration(30 * _sequence->frameCount()); _timeLine->setFrameRange(0, _sequence->frameCount()); _timeLine->setCurveShape(QTimeLine::LinearCurve); _timeLine->setLoopCount(0); // Build the connections connect(_timeLine, SIGNAL(frameChanged(int)), _sequence.data(), SLOT(setActiveFrame(int))); connect(_sequence.data(), SIGNAL(frameChanged(Frame*)), SLOT(frameChanged(Frame*))); // Create scene and attach to graphics view QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(_sequence.data()); graphicsView->setScene(scene); frameChanged(_sequence->frame(0)); _timeBar->update(); // FIXME: Need to call this until a resize event happens. resizeEvent(0); QApplication::restoreOverrideCursor(); }
SelectionPage::SelectionPage(SetupWizard *wizard, QString shapeFile, QWidget *parent) : AbstractWizardPage(wizard, parent), Selection(), ui(new Ui::SelectionPage) { ui->setupUi(this); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(shapeFile); m_shape = new QGraphicsSvgItem(); m_shape->setSharedRenderer(renderer); QGraphicsScene *scene = new QGraphicsScene(this); scene->addItem(m_shape); ui->typeGraphicsView->setScene(scene); connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionChanged(int))); }
// the main device method virtual void run() { if(!opened) { scene->addItem(item); // lock the image viewer img_view_mutex.lock(); // update the pixmap and unlock the image viewer show_image(); // open a window to show the QGraphicsScene view->show(); // set the flag to true opened = true; } else { if (img_view_mutex.try_lock()) { // a new thread! std::thread show_image_thread(&ImageViewerDevice::show_image, this); // leave it alone show_image_thread.detach(); } } }
void Colors::config(double average, double interval) { this->average = average; this->interval = interval; ui->firstMarker->setText(QString::number(average - 2 * interval, 'g', 3)); ui->secondMarker->setText(QString::number(average - interval, 'g', 3)); ui->thirdMarker->setText(QString::number(average, 'g', 3)); ui->fourthMarker->setText(QString::number(average + interval, 'g', 3)); ui->fifthMarker->setText(QString::number(average + 2 * interval, 'g', 3)); QGraphicsScene *scene = new QGraphicsScene(); for (int i = 0; i < ui->graphicsView->width(); i++) { QColor color = widget->getPainter()->getColor(average - 2 * interval + 4 * interval * i / ui->graphicsView->width()); scene->addRect(i, 0, 1, ui->graphicsView->height(), QPen(color), QBrush(color)); } delete ui->graphicsView->scene(); ui->graphicsView->setScene(scene); }
void tst_QGraphicsEffect::opacity() { // Make sure the painter's opacity is correct in QGraphicsEffect::draw. QGraphicsScene scene; CustomItem *item = new CustomItem(0, 0, 100, 100); item->setOpacity(0.5); CustomEffect *effect = new CustomEffect; item->setGraphicsEffect(effect); scene.addItem(item); QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(effect->numRepaints > 0); QCOMPARE(effect->m_opacity, qreal(0.5)); }
MainWindow::MainWindow() { QGraphicsScene *scene = new BackgroundScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 400, 400); setScene(scene); //setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Bezier Curves")); }
void MainWindow::on_actionPrint_triggered() { QGraphicsScene printScene; QPixmap img; QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); dialog->setWindowTitle("Print Coupons"); if (dialog->exec() != QDialog::Accepted) return; QPainter painter(&printer); printScene.setSceneRect(0, 0, 920, 1400); img.loadFromData(coupon.couponFile); coupon.drawCouponPage(&printScene, img, ui->horizontalSlider->value()); printScene.render(&painter); ui->statusBar->showMessage("Coupon page sent to printer."); }
void ParallelMachine::drawLoad(QGraphicsScene &scene) { std::vector<LoadType> load; std::vector<size_t> n_cells, n_particles; for (NodeThreadArray::iterator it = threads.begin(); it != threads.end(); it++) { load.push_back(it->getCurrentLoad()); n_cells.push_back(it->getCurrentNumOfCells()); n_particles.push_back(it->getCurrentNumOfParticles()); } QFontMetrics metrics(scene.font()); const size_t elem_height = (metrics.height() > 20) ? metrics.height() : 20; const LoadType total_load = std::accumulate(load.begin(), load.end(), 0.0); size_t pos_x = 0, pos_y = 0; for (size_t i = 0; i < threads.size(); i++) { pos_x = drawText(scene, QString("%1").arg(i, -3), 0, pos_y).right(); pos_x = drawRect(scene, pos_x, pos_y, len(load[i], total_load, 100), elem_height, Qt::red).right(); pos_x = drawRect(scene, pos_x, pos_y, len(n_cells[i], total_num_of_cells, 100), elem_height, Qt::green).right(); pos_x = drawRect(scene, pos_x, pos_y, len(n_particles[i], total_num_of_particles, 100), elem_height, Qt::blue).right(); pos_x = drawText(scene, QString("L: %1, C: %2, P: %3"). arg(load[i]).arg(n_cells[i]).arg(n_particles[i]), pos_x, pos_y).right(); pos_y += elem_height + 2; } drawText(scene, QString("Max diff: L: %1, C: %2, P: %3"). arg(diff(load)).arg(diff(n_cells)).arg(diff(n_particles)), 0, pos_y).right(); }
void MainWindow::on_selectPicture_clicked() { //get image fname QFileDialog dialog; dialog.setFileMode(QFileDialog::AnyFile); dialog.setNameFilter("Image files (*.png *.xpm *.jpg *.bmp *.jpeg)"); if(dialog.exec()==0 || dialog.selectedFiles().size()==0 ) return; imageToSearch = dialog.selectedFiles()[0]; //display QGraphicsScene *scn = new QGraphicsScene(ui->imageView); scn->setSceneRect(QRect(1,1,ui->imageView->rect().width()-2,ui->imageView->rect().height()-2)); ui->imageView->setScene(scn); QPixmap pix(imageToSearch); scn->addPixmap(pix); }
MDIViewPage* QGIView::getMDIViewPage(void) const { MDIViewPage* result = nullptr; QGraphicsScene* s = scene(); QObject* parent = nullptr; if (s != nullptr) { parent = s->parent(); } if (parent != nullptr) { MDIViewPage* mdi = dynamic_cast<MDIViewPage*>(parent); if (mdi != nullptr) { result = mdi; } } return result; }
void tst_QGraphicsLayout::compressLayoutRequest() { QGraphicsView view; QGraphicsScene scene; TestGraphicsWidget *tw = new TestGraphicsWidget(); scene.addItem(tw); view.show(); QGraphicsLinearLayout *lout = new QGraphicsLinearLayout(tw); for (int i = 0; i < 4; ++i) { QGraphicsWidget *gw = new QGraphicsWidget(tw); gw->setPreferredSize(QSizeF(50, 50)); lout->addItem(gw); } QApplication::processEvents(); QCOMPARE(tw->eventCount(QEvent::LayoutRequest), 1); }
Form::Form(QWidget *parent) : QWidget(parent) { this->setupUi(this); //connect( this->ui.pushButton, SIGNAL( clicked() ), this, SLOT(pushButton_SetLabelText()) ); QColor sceneBackgroundColor; sceneBackgroundColor.setRgb(153, 255, 0); QGraphicsScene* scene = new QGraphicsScene(); QBrush brush; brush.setStyle(Qt::SolidPattern); brush.setColor(sceneBackgroundColor); scene->setBackgroundBrush(brush); this->graphicsView->setScene(scene); }
DialogSplash::DialogSplash(QWidget *parent) : QDialog(parent), ui(new Ui::DialogSplash) { ui->setupUi(this); setModal(true); setWindowFlags(Qt::SplashScreen); QGraphicsScene *scene = new QGraphicsScene(this); scene->addPixmap(QPixmap(":/embedded/share/logo.svg")); ui->graphicsView->setResizeAnchor(QGraphicsView::AnchorViewCenter); ui->graphicsView->setScene(scene); ui->graphicsView->scroll(ui->graphicsView->width()/2, ui->graphicsView->height()/2); }
SelectWindow::SelectWindow(QWidget *parent) : QWidget(parent), ui(new Ui::SelectWindow) { ui->setupUi(this); //ui->graphicsView->installEventFilter(this); QGraphicsScene *scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); canvas_ = new SelectCanvas; scene->addItem(canvas_); canvas_->grabKeyboard(); canvas_->load(); }
GameController::GameController(QGraphicsScene &scene, QObject *parent) : QObject(parent), scene(scene), snake(new Snake(*this)) { timer.start(1000/33); //Food *a1 = new Food(0, -50); addNewFood(); //scene.addItem(a1); scene.addItem(snake); scene.installEventFilter(this); resume(); }
WristWidget::WristWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 50, 50); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(1), qreal(1)); setMinimumSize(50, 50); setWindowTitle(tr("Elastic Nodes")); wristAngle = 0; int x = WRIST_WIDTH / 2 * cos(wristAngle); int y = WRIST_WIDTH / 2 * sin(wristAngle); Line *line = new Line( WRIST_CENTER_X - x, WRIST_CENTER_Y + y, WRIST_CENTER_X + x, WRIST_CENTER_Y - y); line->setTransformOriginPoint(WRIST_CENTER_X,WRIST_CENTER_Y); x = WRIST_HEIGHT * cos(wristAngle + M_PI / 2); y = WRIST_HEIGHT * sin(wristAngle + M_PI / 2); QGraphicsLineItem *line2 = new QGraphicsLineItem( WRIST_CENTER_X, WRIST_CENTER_Y, WRIST_CENTER_X + x, WRIST_CENTER_Y - y); line->setPen(QPen(Qt::red,WRIST_LINE_WIDTH)); line2->setPen(QPen(Qt::red,WRIST_LINE_WIDTH)); // make the line be able to rotate around the origin point given as parameters line->setFlag(line->ItemIsMovable); line->setTransformOriginPoint(WRIST_CENTER_X, WRIST_CENTER_Y); scene->addItem(line); scene->addItem(line2); timerId = startTimer(1000 / 25); }
/*! */ void GridItem::moveBall(BallItem *ball, const QVector<GridPos> &path) { if (!ball) { qDebug() << "GridItem::moveBall(...): pointer to the ball item is NULL"; return; } QVector<GridPos> tmpPath(path); // skip the first square GridPos firstPos = tmpPath.front(); freePos(firstPos); // // the source square becomes available BallItemsProvider::instance()->fromUsedToAvailable(firstPos); // QGraphicsScene *theScene = scene(); Q_ASSERT(theScene); Q_ASSERT(theScene->views().isEmpty() == false); theScene->views()[0]->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); foreach(GridPos pos, tmpPath) { if (pos != tmpPath.back()) { // do not store the ball item on the positions of the intermediate squares (the 3rd argument // is set to false). showBall(ball, pos, false); pause(100); } else { // is there any hint ball onto the target square ? BallItem *hintBall = ballAt(pos); if (hintBall) { hideBall(hintBall); delete hintBall; BallItemsProvider::instance()->removeHint(hintBall); } // stores the ball item on the position of the target square. showBall(ball, pos, true); } // also wipes the path tracks square by square m_pathTracker.removeFrontLine(); update(); } }
bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeMouseArea); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); QGraphicsScene *s = scene(); QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0; bool stealThisEvent = d->stealMouse; if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); for (int i = 0x1; i <= 0x10; i <<= 1) { if (event->buttons() & i) { Qt::MouseButton button = Qt::MouseButton(i); mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); } } mouseEvent.setScenePos(event->scenePos()); mouseEvent.setLastScenePos(event->lastScenePos()); mouseEvent.setPos(mapFromScene(event->scenePos())); mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); switch(mouseEvent.type()) { case QEvent::GraphicsSceneMouseMove: mouseMoveEvent(&mouseEvent); break; case QEvent::GraphicsSceneMousePress: mousePressEvent(&mouseEvent); break; case QEvent::GraphicsSceneMouseRelease: mouseReleaseEvent(&mouseEvent); break; default: break; } grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()); if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) grabMouse(); return stealThisEvent; } if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { d->stealMouse = false; ungrabMouse(); } return false; }
void MainWindow::on_recoverThread_updateStatus(const DdrescueStatus &status, DdrescueLog const &log) { ui->lblRescuedValue->setText(formatBytes(status.rescued())); ui->lblIposValue->setText(formatBytes(status.ipos())); ui->lblOposValue->setText(formatBytes(status.opos())); ui->lblErrsizeValue->setText(formatBytes(status.errsize())); ui->lblErrorsValue->setText(QString::number(status.errors())); ui->lblAvgRateValue->setText(formatBytes(status.averageRate()) + "/s"); ui->lblCurrRateValue->setText(formatBytes(status.currentRate()) + "/s"); ui->lblTimeFrom->setText(QString::number(status.timeFromLastSuccessfulRead()) + " s"); ui->lblStatus->setText(status.status()); QGraphicsScene *scene = ui->graph->scene(); if (!scene) { scene = new QGraphicsScene(); ui->graph->setScene(scene); } scene->clear(); qreal width = ui->graph->width()-5; qreal height = ui->graph->height()-5; scene->addRect(0,0,width,height,QPen(QColor(Qt::blue)), QBrush(QColor(Qt::blue))); long long sizeTotal = 0; for (int i = 0; i < log.blocks().size(); i++) { sizeTotal += log.blocks().at(i).size; } qreal wfactor = sizeTotal / width; if (sizeTotal > 0) { for (int i = 0; i < log.blocks().size(); i++) { qreal x = log.blocks().at(i).pos/wfactor; qreal w = log.blocks().at(i).size/wfactor; scene->addRect(x,0 ,w,height ,QPen(statusBlock2QColor(log.blocks().at(i).status)) , QBrush(statusBlock2QColor(log.blocks().at(i).status))); } } scene->addText(formatBytes(sizeTotal)); }
JournalGUI_ExerciseCard::JournalGUI_ExerciseCard( QWidget* theParent ) : QGraphicsView( theParent ) { myShrink = 0.8; myDelta = -10; myShadowColor = QColor( 64, 64, 64, 200 ); myBlurRadius = 20; myIsFinished = false; QGraphicsScene* aScene = new QGraphicsScene( this ); setScene( aScene ); setWindowFlags( Qt::Window | Qt::FramelessWindowHint ); setAttribute( Qt::WA_TranslucentBackground ); setFrameShape( QFrame::NoFrame ); myShadowItem = new QGraphicsRectItem(); myShadowItem->setBrush( myShadowColor ); QGraphicsBlurEffect* aBlur = new QGraphicsBlurEffect( this ); aBlur->setBlurRadius( myBlurRadius ); myShadowItem->setGraphicsEffect( aBlur ); aScene->addItem( myShadowItem ); QFrame* aMainFrame = new QFrame( 0 ); QVBoxLayout* aLayout = new QVBoxLayout( aMainFrame ); QGridLayout* aMainLayout = new QGridLayout( 0 ); QHBoxLayout* aStatusLayout = new QHBoxLayout( 0 ); aLayout->addLayout( aMainLayout, 1 ); aLayout->addLayout( aStatusLayout, 0 ); myStateLabel = new QLabel( "", this ); aStatusLayout->addWidget( myStateLabel, 1 ); myVerify = new QPushButton( tr( "Verify" ), this ); connect( myVerify, SIGNAL( clicked() ), this, SLOT( OnFinish() ) ); aStatusLayout->addWidget( myVerify, 0 ); myNext = new QPushButton( tr( "Next" ), this ); connect( myNext, SIGNAL( clicked() ), this, SIGNAL( next() ) ); aStatusLayout->addWidget( myNext, 0 ); aMainLayout->setColumnStretch( 0, 1 ); aMainLayout->setRowStretch( MAX_NB_ROWS, 1 ); myFrameItem = aScene->addWidget( aMainFrame ); }
QWidget *QuickTestEvent::eventWidget() { QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(parent()); if (!item) return 0; QGraphicsScene *s = item->scene(); while (!s && item) { item = qobject_cast<QDeclarativeItem *>(item->parent()); s = item->scene(); } if (!s) return 0; QList<QGraphicsView *> views = s->views(); if (views.isEmpty()) return 0; return views.at(0); }
void PheromoneItem::evaporatePheromone() { if(pheromoneValue - evaporationRate > 0){ decrementPheromoneValue(evaporationRate); update(); }else{ // canPaint = false; QGraphicsScene *esc = scene(); if(esc){ esc->removeItem(this); // lastPheromones.clear(); } emit pheromoneDeleted(this); disconnect(); delete this; } }
/* * Initialize the widget */ GpsDisplayWidget::GpsDisplayWidget(QWidget *parent) : QWidget(parent) { setupUi(this); //Not elegant, just load the image for now QGraphicsScene *fescene = new QGraphicsScene(this); QPixmap earthpix( ":/gpsgadget/images/flatEarth.png" ); fescene->addPixmap( earthpix ); flatEarth->setScene(fescene); marker = new QGraphicsSvgItem(); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/gpsgadget/images/marker.svg")); marker->setSharedRenderer(renderer); fescene->addItem(marker); double scale = earthpix.width()/(marker->boundingRect().width()*20); marker->setScale(scale); }
SEXP qt_qaddItem_QGraphicsScene(SEXP s, SEXP ritem) { // #define unwrapQGraphicsItem(x, type) ({ \ // type *ans = qgraphicsitem_cast<type *>(unwrapQGraphicsItemReferee(x)); \ // if (!ans) error("unwrapQGraphicsItem: Coercion to " #type " failed"); \ // ans; \ // }) QGraphicsScene *scene = unwrapQObject(s, QGraphicsScene); // unwrapQGraphicsItemReferee(ritem); QGraphicsItem *item = unwrapQGraphicsItem(ritem, QGraphicsItem); // failing scene->addItem(item); // Make sure that item is not deleted before its scene // FIXME: leaky -- needs to happen in itemChange() upon ItemSceneChange, // but that requires always using a QGraphicsWidget subclass addQGraphicsItemReference(item, scene); return s; }
QImage applyEffectToImage(const QImage src, QGraphicsEffect *effect, int extent = 0) { if (src.isNull()) { return QImage(); } if (!effect) { return src; } QGraphicsScene scene; QGraphicsPixmapItem item; item.setPixmap(QPixmap::fromImage(src)); item.setGraphicsEffect(effect); scene.addItem(&item); QImage res(src.size() + QSize(extent * 2, extent * 2), QImage::Format_ARGB32); res.fill(Qt::transparent); QPainter ptr(&res); scene.render(&ptr, QRectF(), QRectF(-extent, -extent, src.width() + extent * 2, src.height() + extent * 2)); return res; }
Form::Form(QWidget *parent) : QWidget(parent) { setupUi(this); QGraphicsScene* scene = new QGraphicsScene(); this->graphicsView->setScene(scene); //this->graphicsView->setDragMode(QGraphicsView::RubberBandDrag); this->graphicsView->show(); QPixmap pixmap(100,100); pixmap.fill(QColor(255,0,0)); QGraphicsPixmapItem* item = scene->addPixmap(pixmap); item->setFlag(QGraphicsItem::ItemIsMovable); }
void Ut_LockScreenStatusAreaView::testOrientationChangeUpdatesStatusBarGeometry() { QGraphicsScene scene; QGraphicsView view; view.setScene(&scene); scene.addItem(statusArea); statusArea->setGeometry(QRectF(5, 10, 15, 20)); m_subject->updateStatusBarGeometryProperty(); testStatusBarGeometryProperty(); // Setting the same geometry should do nothing m_subject->updateStatusBarGeometryProperty(); QCOMPARE(xChangePropertyCallCount, 1); scene.removeItem(statusArea); }
void PartsEditorSketchWidget::clearScene() { QGraphicsScene * scene = this->scene(); //QList<QGraphicsItem*> items; for(int i=0; i < scene->items().size(); i++){ ItemBase * itemBase = ItemBase::extractTopLevelItemBase(scene->items()[i]); if (itemBase == NULL) { //items << scene->items()[i]; continue; } this->deleteItem(itemBase, true, true); } /*for(int i=0; i < items.size(); i++) { scene->removeItem(items[i]); }*/ }