コード例 #1
0
ファイル: tst_qgraphicseffect.cpp プロジェクト: RS102839/qt
void tst_QGraphicsEffect::inheritOpacity()
{
    QGraphicsScene scene;
    QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10);
    CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem);

    scene.addItem(rectItem);

    item->setGraphicsEffect(new DeviceEffect);
    item->setPen(Qt::NoPen);
    item->setBrush(Qt::red);

    rectItem->setOpacity(0.5);

    QGraphicsView view(&scene);
    view.show();
    QTest::qWaitForWindowShown(&view);

    QTRY_VERIFY(item->numRepaints >= 1);

    int numRepaints = item->numRepaints;

    rectItem->setOpacity(1);

    // item should have been rerendered due to opacity changing
    QTRY_VERIFY(item->numRepaints > numRepaints);
}
コード例 #2
0
ファイル: Game.cpp プロジェクト: Selfer/ICP-2015
void Game::drawPanel(int x, int y, int width, int height, QColor color, double opacity){
    QGraphicsRectItem* panel = new QGraphicsRectItem(x,y,width,height);
    QBrush br;
    br.setStyle(Qt::SolidPattern);
    br.setColor(color);
    panel->setBrush(br);
    panel->setOpacity(opacity);
    scene->addItem(panel);
}
コード例 #3
0
ファイル: BoardView.cpp プロジェクト: rouffj/gomoku
void BoardView::setWinningText(std::string const & text)
{
    this->_winner = text;
    this->getGameInfos()._ui.gameStatusLabel->setText(text.c_str());
    QGraphicsRectItem* rectItem = this->_scene.addRect(0, 0, this->_scene.width(), this->scene()->height(), QPen(Qt::white), QBrush(Qt::white));
    rectItem->setOpacity(0.8);
    QGraphicsTextItem* textItem = this->_scene.addText(text.c_str(), QFont("Ubuntu, Calibri", 24, 600));
    textItem->adjustSize();
    textItem->setPos(((this->_board->getSize() * this->_lineSpacing - textItem->textWidth()) / 2), 100);
}
コード例 #4
0
void GamePlay::displayGameOver(int highScore)
{
    for (size_t i = 0, n=scene->items().size();i<n;i++)
        scene->items()[i]->setEnabled(false);
    timer->stop();
    QGraphicsRectItem *panel = new QGraphicsRectItem(160,120,300,320);
    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(Qt::yellow);
    panel->setBrush(brush);
    panel->setOpacity(0.65);
    scene->addItem(panel);
    QGraphicsTextItem *gameOverText = new QGraphicsTextItem(QString("GAME OVER!\nYour score:")+QString::number(highScore));
    gameOverText->setDefaultTextColor(Qt::magenta);
    gameOverText->setFont(QFont("Pixelette",20));
    gameOverText->setPos(185,160);
    scene->addItem(gameOverText);
}