void DigestTreeScene::updateNode(QString sessionPrefix, QString nick, uint64_t seqNo) { Roster_iterator it = m_roster.find(sessionPrefix); if (it == m_roster.end()) { DisplayUserPtr p(new DisplayUser()); p->setPrefix(sessionPrefix); p->setSeq(seqNo); m_roster.insert(p->getPrefix(), p); plot(m_rootDigest); } else { it.value()->setSeq(seqNo); DisplayUserPtr p = it.value(); QGraphicsTextItem *item = p->getSeqTextItem(); QGraphicsRectItem *rectItem = p->getInnerRectItem(); std::string s = boost::lexical_cast<std::string>(p->getSeqNo()); item->setPlainText(s.c_str()); QRectF textBR = item->boundingRect(); QRectF rectBR = rectItem->boundingRect(); item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2, rectBR.y() + (rectBR.height() - textBR.height())/2); } m_displayRootDigest->setPlainText(m_rootDigest); updateNick(sessionPrefix, nick); }
WeiboDialogPrivate() { api = new WeiboApi; qreal x = 6; QGraphicsTextItem *title = new QGraphicsTextItem(titleBar); title->setPos(x, 12); title->setDefaultTextColor(Qt::white); QFont f; f.setPixelSize(23); f.setBold(true); title->setFont(f); title->setPlainText(QObject::tr("New weibo (Sina)")); qreal w = qApp->desktop()->width()/2 - 44; statusEdit = new TextEdit(central); statusEdit->setFont(f); statusEdit->setDefaultTextColor(Qt::blue); statusEdit->document()->setDocumentMargin(22); qreal y = 22; statusEdit->setPos(x, y); statusEdit->document()->setTextWidth(qApp->desktop()->width()/2 - 8); //statusEdit->setPlainText("Write something..."); qreal h = qApp->desktop()->height()*0.618; statusEdit->resize(w, h); y += statusEdit->size().height() + 12; qreal hh = qMin<qreal>(qApp->desktop()->height()*0.314/2, 40); //TODO: calculate the line edit height f.setBold(true); QGraphicsTextItem *user = new QGraphicsTextItem(central); f.setPixelSize(20); user->setFont(f); user->document()->setDocumentMargin(4); user->setDefaultTextColor(QColor(33, 33, 33)); user->setPlainText(QObject::tr("User")); user->setPos(x, y); userEdit = new TextEdit(central); userEdit->setPos(x + 120, y); userEdit->resize(w - 120, hh); userEdit->setDefaultTextColor(Qt::black); userEdit->document()->setDocumentMargin(11); userEdit->document()->setTextWidth(qApp->desktop()->width()/2 - 8); y += hh + 2; QGraphicsTextItem *passwd = new QGraphicsTextItem(central); passwd->setFont(f); passwd->document()->setDocumentMargin(4); passwd->setDefaultTextColor(QColor(33, 33, 33)); passwd->setPlainText(QObject::tr("Password")); passwd->setPos(x, y); passwdEdit = new TextEdit(central); passwdEdit->setPos(x + 120, y); passwdEdit->resize(w - 120, hh); passwdEdit->setDefaultTextColor(Qt::black); passwdEdit->document()->setDocumentMargin(11); statusEdit->setTextInteractionFlags(Qt::TextEditorInteraction); userEdit->setTextInteractionFlags(Qt::TextEditorInteraction); passwdEdit->setTextInteractionFlags(Qt::TextEditorInteraction); f.setPixelSize(24); userEdit->setFont(f); passwdEdit->setFont(f); passwdEdit->setEchoMode(TextEdit::Password); }
void mainWindow :: setAxisNames(QString xname, QString yname) { QGraphicsTextItem *xn = pscene->addText(xname); QGraphicsTextItem *yn = pscene->addText(yname); xn -> setDefaultTextColor(NamesCOLOR); yn -> setDefaultTextColor(NamesCOLOR); xn->setPos(GrWIDTH-50,GrHEIGHT/2+20); yn->setPos(50, 30); }
/* Function to draw the title text. @detail This fuction draws the welcome and help text. */ void GraphicsScene::DrawTitle() { //Add the title text QGraphicsTextItem* title = new QGraphicsTextItem(TITLE); title->setPos((CANVAS_WIDTH-METRICS.width(TITLE))/2,PADDING_TITLE); addItem(title); //Add the info text QGraphicsTextItem* info = new QGraphicsTextItem(INFO); info->setPos((CANVAS_WIDTH-METRICS.width(INFO))/2,PADDING_TITLE+METRICS.height()); addItem(info); }
void MainWindow::draw_legend(QPointF const& start) { QGraphicsTextItem* var = scene->addText("VAR", legend_font); QPointF nstart = QPointF(start.x() -var->boundingRect().size().width(), start.y() -var->boundingRect().size().height()); var->setPos(nstart); var->setDefaultTextColor(clr_var); QGraphicsTextItem* abs = scene->addText("ABS", legend_font); abs->setPos(nstart.x(), nstart.y() -11); abs->setDefaultTextColor(clr_abs); QGraphicsTextItem* app = scene->addText("APP", legend_font); app->setPos(nstart.x(), nstart.y() -22); app->setDefaultTextColor(clr_app); }
BattleAbilitySelection::BattleAbilitySelection(QGraphicsItem *parent) : QGraphicsPixmapItem(parent), _currentBattler(0), _abilities(0), _abilityIndex(0), _messageItem(0), _items(0), _activeItems(0), _state(ACTIONSELECTION), _action(BattleAction::ATTACK), _currentItem(0) { createWindow(); QFont font ("Times", 12, QFont::Bold); _messageItem = new QGraphicsTextItem(this); _messageItem->setTextWidth(boundingRect().width() - 50); _messageItem->setDefaultTextColor(Qt::white); _messageItem->setFont(font); _messageItem->setPos(25, 10); int x = 25, y = 40; for (int i = 0; i < 4; i++) { QGraphicsTextItem *item = new QGraphicsTextItem(this); item->hide(); item->setTextWidth(boundingRect().width() - 25); item->setDefaultTextColor(Qt::white); item->setFont(font); item->setPos(x, y); y += 30; _items.append(item); } }
void RSceneDevice::TextUTF8(double x, double y, char *str, double rot, double hadj, R_GE_gcontext *gc) { if (debug) Rprintf("RSceneDevice::TextUTF8\n"); int col = gc->col; //double gamma = gc->gamma; double cex = gc->cex; double ps = gc->ps; double lineheight = gc->lineheight; int fontface = gc->fontface; char* fontfamily = gc->fontfamily; // [201] ?? QString qstr = QString::fromUtf8(str); QGraphicsTextItem *text = addText(qstr, r2qFont(fontfamily, fontface, ps, cex, lineheight, defaultFamily())); text->setDefaultTextColor(r2qColor(col)); QRectF brect = text->boundingRect(); text->rotate(-rot); text->translate(-hadj * brect.width(), -0.7 * brect.height()); text->setPos(x, y); addClippedItem(text); return; }
HelpText(MyScene *scene){ QFont font = g_editor->main_window->font(); font.setPointSize(15); font.setPixelSize(15); // When is this text shown? _text = scene->addText( // "* Add objects with right mouse button\n" "* Move objects with right mouse button.\n" "\n" "* Double-click the name of an object to open GUI. (only if there is one)\n" "\n" "* Delete objects or connections by pressing SHIFT and click left.\n" " - Alternatively, click with middle mouse button.\n" "\n" "* Select more than one object by holding CTRL when clicking.\n" " - Alternatively, mark an area of objects with left mouse button.\n" "\n" "* To autoconnect a new object to an existing object, right click at the input or output of an existing object.\n" "\n" "* Zoom in and out by pressing CTRL and using the scroll wheel.\n" , font); _text->setDefaultTextColor(get_qcolor(HIGH_BACKGROUND_COLOR_NUM).light(70)); _text->setPos(-150,-150); _text->setZValue(-1000); setSingleShot(true); setInterval(1000*60); start(); }
//! [3] void View::addItems() { int officeCount = officeTable->rowCount(); int imageOffset = 150; int leftMargin = 70; int topMargin = 40; for (int i = 0; i < officeCount; i++) { ImageItem *image; QGraphicsTextItem *label; QSqlRecord record = officeTable->record(i); int id = record.value("id").toInt(); QString file = record.value("file").toString(); QString location = record.value("location").toString(); int columnOffset = ((i / 3) * 37); int x = ((i / 3) * imageOffset) + leftMargin + columnOffset; int y = ((i % 3) * imageOffset) + topMargin; image = new ImageItem(id, QPixmap(":/" + file)); image->setData(0, i); image->setPos(x, y); scene->addItem(image); label = scene->addText(location); QPointF labelOffset((150 - label->boundingRect().width()) / 2, 120.0); label->setPos(QPointF(x, y) + labelOffset); } }
void XYRobot::initRobotCanvas() { origin = QPoint((scene->width()-p_width)/2,(scene->height()-p_height)/2); //check item needed if(pRect!=NULL) { //scene->removeItem(pRect); } QPen pen(QColor(124,124,124)); pRect = scene->addRect(origin.x(),origin.y(),p_width,p_height,pen); QGraphicsTextItem* pTxt = scene->addText("0"); QPoint cent((origin.x()-10),origin.y()+p_height); pTxt->setPos(cent); pTxt->setDefaultTextColor(QColor(124,124,124)); txtPtr.append(pTxt); QGraphicsTextItem* pTxt1 = scene->addText("Y"); cent = QPoint(origin.x()-10,origin.y()-10); pTxt1->setPos(cent); pTxt1->setDefaultTextColor(QColor(124,124,124)); txtPtr.append(pTxt1); QGraphicsTextItem* pTxt2 = scene->addText("X"); cent = QPoint(origin.x()+p_width,origin.y()+p_height); pTxt2->setPos(cent); pTxt2->setDefaultTextColor(QColor(124,124,124)); txtPtr.append(pTxt1); }
/**@brief creates a new display to indicate that the player has lost and needs to restart */ void Game::display_game_over() { qDebug() << "game over."; level->input->releaseKeyboard(); level->clear(); delete level; level = nullptr; //clear the screen from the level scene = new QGraphicsScene(); setScene(scene); //next create the Game Over text QGraphicsTextItem* gameOverText = new QGraphicsTextItem(QString("You Perished. Game Over.")); //set font and size QFont game_over_font ("28 Days Later", 25); gameOverText->setFont(game_over_font); //position the text int gameOverXPos = this->width()/2 - gameOverText->boundingRect().width()/2; int gameOverYPos = 150; gameOverText->setPos(gameOverXPos, gameOverYPos); //add it to the scene scene->addItem(gameOverText); //create back to main menu button Button* returnToMenu = new Button(QString("Return to Menu")); //position button int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2; int returnYPos = 425; returnToMenu->setPos(returnXPos, returnYPos); //connect this button to quit the game QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu())); scene->addItem(returnToMenu); }
/**@brief displays a new screen to indicate that the player has won the game */ void Game::display_end_screen() { level->input->releaseKeyboard(); level->clear(); delete level; level = nullptr; //clear the screen from the level scene = new QGraphicsScene(); setScene(scene); //next create the end screen text QGraphicsTextItem* endText = new QGraphicsTextItem(QString("You defeated all the demons! Congratulations Champion!")); //set font and size QFont endFont ("Adventure", 25); endText->setFont(endFont); //position the text int endXPos = this->width()/2 - endText->boundingRect().width()/2; int endYPos = 150; endText->setPos(endXPos, endYPos); //add it to the scene scene->addItem(endText); //create back to main menu button Button* returnToMenu = new Button(QString("Return to Menu")); //position button int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2; int returnYPos = 425; returnToMenu->setPos(returnXPos, returnYPos); //connect this button to quit the game QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu())); scene->addItem(returnToMenu); }
MagicMenuItem::MagicMenuItem() { int itemSize = 55; setRect( -itemSize/2, -itemSize/2, itemSize, itemSize ); setBrush( QColor( 230,229,229 ) ); QPen pen; pen.setBrush( Qt::NoBrush ); setPen( pen ); QGraphicsTextItem *textItem = new QGraphicsTextItem( i18n("Magic"), this ); int textWidth = textItem->boundingRect().width(); int textHeight = textItem->boundingRect().height(); textItem->setPos( - textWidth / 2, - textHeight / 2 ); m_fanMenu = new FanMenu( this ); m_fanMenu->setZValue( 50 ); m_fanMenu->hide(); m_fanMenu->setStartAngle( 80 ); m_fanMenu->setEndAngle( 280 ); FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Reset\nlayout") ); connect( menuItem, SIGNAL( clicked() ), SIGNAL( resetLayout() ) ); menuItem = m_fanMenu->addItem( i18n("Settings") ); connect( menuItem, SIGNAL( clicked() ), SIGNAL( showSettings() ) ); m_fanMenu->setupItems( 80 ); setAcceptHoverEvents( true ); }
/**@brief shows a set of instructions for the user to understand gameplay */ void Game::display_instructions() { //start by clearing the scene from the Main Menu scene->clear(); //next we create the instructions portion QGraphicsTextItem* instructionsText = new QGraphicsTextItem (QString("You are about to embark on an epic quest champion! In order to protect the\n" "Emerald Dream, you must cleanse the land of demons. Use WASD or the arrow\n" "keys to move around and Spacebar to fire your wrath attack. At any time you\n" "can hit escape if the battle becomes too intense. Beware of the demons, if they\n" "cross the threshold this will lower your health. If your health reaches 0, you\n" "lose the game. If you kill 10 of the demons, you win! You have all you need\n" "now fulfill your druidic duties! May Elune be with you!")); //set the font and size QFont instructFont ("Lithos Pro", 17); instructionsText->setFont(instructFont); //position the text int instructXPos = this->width()/2 - instructionsText->boundingRect().width()/2; int instructYPos = 150; instructionsText->setPos(instructXPos, instructYPos); //add it to the scene scene->addItem(instructionsText); //create the Back to Main Menu Button Button* returnToMenu = new Button(QString("Return to Menu")); //position button int returnXPos = this->width()/2 - returnToMenu->boundingRect().width()/2; int returnYPos = 425; returnToMenu->setPos(returnXPos, returnYPos); //connect this button to quit the game QObject::connect(returnToMenu, SIGNAL(clicked()), this, SLOT(displayMainMenu())); scene->addItem(returnToMenu); }
SEXP scene_addText(SEXP scene, SEXP x, SEXP y, SEXP labels, SEXP html) { QGraphicsScene* s = unwrapQObject(scene, QGraphicsScene); int nlab = length(labels); int i, n = length(x); for (i = 0; i < n; i++) { QGraphicsTextItem *ti = s->addText(QString()); ti->setFont(QFont("Arial")); if (LOGICAL(html)[0]) { ti->setHtml(QString::fromLocal8Bit(CHAR(asChar(STRING_ELT(labels, i % nlab))))); ti->setOpenExternalLinks(true); ti->setToolTip("I am HTML!"); } else { ti->setPlainText(QString::fromLocal8Bit(CHAR(asChar(STRING_ELT(labels, i % nlab))))); } ti->setPos(REAL(x)[i], REAL(y)[i]); ti->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIgnoresTransformations); } return R_NilValue; }
void MainWindow::on_pushButton_clicked() { QGraphicsEllipseItem *ellipse2; QGraphicsTextItem *texto; QBrush redBrush(Qt::red); //QBrush blueBrush(Qt::blue); QPen blackPen(Qt::black); blackPen.setWidth(1); ellipse1 = scene->addEllipse(0, 10, 100, 100, blackPen, redBrush); ellipse2 = scene->addEllipse(500, 10, 100, 100, blackPen, redBrush); ellipse1->setAcceptDrops(true); ellipse2->setAcceptDrops(true); ellipse1->setFlag(QGraphicsItem::ItemIsMovable, true); texto = new QGraphicsTextItem(); texto->setPos(0,50); texto->setPlainText("Nodo X"); Nodo1->addToGroup(ellipse1); Nodo1->addToGroup(texto); Nodo1->setAcceptDrops(true); Nodo1->setFlag(QGraphicsItem::ItemIsMovable, true); scene->addItem(Nodo1); ui->painter->setAcceptDrops(true); ui->painter->setScene(scene); ui->painter->scale(currentScale,currentScale); }
Plansza::Plansza(int liczbaGraczy, QObject *parent) : QGraphicsScene(parent), _liczbaGraczy(liczbaGraczy) { _stol = vector<Karta>(liczbaGraczy); _deklaracje = vector<int>(liczbaGraczy); _wziete = vector<int>(liczbaGraczy); _punkty = vector<int>(liczbaGraczy, 0); karty = QVector<QVector<KartaSprite*> >(liczbaGraczy); _nrLewy = 1; // deklaracje Items QFont font; font.setBold(true); font.setPixelSize(25); QGraphicsTextItem *item; for (int i = 0; i < liczbaGraczy; i++) { item = new QGraphicsTextItem; item->setPlainText(tr("?")); item->setFont(font); item->setPos(0, i*50); addItem(item); deklaracjeItems.push_back(item); } setBackgroundBrush(Qt::green); //setSceneRect(0, 0, 1000, 1000); }
void widgetLandmark::NewRegion() { ui->add_button->setChecked(false); // show ellipse and text in graphics view QPen pen = QPen(Qt::darkGreen,2); pen.setCosmetic(true); QRectF rect = _gview->GetCurrentSelectRect()->rect(); QGraphicsEllipseItem* ellipse = _gview->GetScene()->addEllipse(rect,pen); ellipse->setTransform(QTransform::fromTranslate(_gview->GetTranslationX(),_gview->GetTranslationY()), true); // create region jpsRegion* region = new jpsRegion(_dmanager->GetRegionCounter(),"Region"+QString::number(_dmanager->GetRegionCounter()), rect.center(),std::fabs(rect.width()/2.0),std::fabs(rect.height()/2.0)); QGraphicsTextItem* text = _gview->GetScene()->addText(region->GetCaption()); text->setPos(rect.center().x()+_gview->GetTranslationX(),rect.center().y()+_gview->GetTranslationY()); //text->setScale(gl_scale_f); text->setData(0,_gview->GetScaleF()); text->setTransform(QTransform::fromScale(_gview->GetScaleF(),-_gview->GetScaleF()),true); region->SetTextItem(text); region->SetEllipse(ellipse); _dmanager->NewRegion(region); //show Region in listwidget ShowRegions(); }
void widgetLandmark::SetPosInCMap() { jpsLandmark* landmark = GetCurrentLandmark(); if (landmark!=nullptr) { landmark->SetRect(_gview->GetCurrentSelectRect()->rect()); QString string = "Ellipse: x: "+QString::number(landmark->GetRect().center().x()) + " y: "+QString::number(landmark->GetRect().center().y())+" rA: "+QString::number(landmark->GetA()) + " rB: "+QString::number(landmark->GetB()); ui->ellipse_label->setText(string); ui->add_button->setChecked(false); // show ellipse and text in graphics view QPen pen = QPen(Qt::blue,2); pen.setCosmetic(true); QGraphicsEllipseItem* ellipse = _gview->GetScene()->addEllipse(landmark->GetRect(),pen); ellipse->setTransform(QTransform::fromTranslate(_gview->GetTranslationX(),_gview->GetTranslationY()), true); QGraphicsTextItem* text = _gview->GetScene()->addText(landmark->GetCaption()); text->setPos(landmark->GetPos().x()+_gview->GetTranslationX(),landmark->GetPos().y()+_gview->GetTranslationY()); //text->setScale(gl_scale_f); text->setData(0,_gview->GetScaleF()); text->setTransform(QTransform::fromScale(_gview->GetScaleF(),-_gview->GetScaleF()),true); landmark->SetEllipseItem(ellipse); landmark->SetTextItem(text); } }
void Main::addText() { QGraphicsTextItem* i = canvas.addText("QCanvasText"); i->setFlag(QGraphicsItem::ItemIsMovable); i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); i->setZValue(qrand()%256); }
// ###################################################################### void ScorbotConsole::updatePlots() { itsGraphicsView->setBackgroundBrush(QBrush(Qt::darkGray)); //Clear all previous plots QList<QGraphicsItem*> items = itsGraphicsScene->items(); for(int i=0; i<items.size(); i++) { itsGraphicsScene->removeItem(items[i]); delete items[i]; } int textPos = -5000; int textOffset=500; QMap<QString, bool>::iterator dataCheckIt = plotDataCheck.begin(); for(; dataCheckIt != plotDataCheck.end(); ++dataCheckIt) { if (dataCheckIt.value() && plotData.contains(dataCheckIt.key())) { PixRGB<byte> color = plotDataColor[dataCheckIt.key()]; QGraphicsTextItem *text = itsGraphicsScene->addText(dataCheckIt.key()); text->setDefaultTextColor(QColor(color.red(), color.green(), color.blue())); text->setPos(1, textPos); text->setFlags(QGraphicsItem::ItemIgnoresTransformations); textPos+=textOffset; plotLine(plotData[dataCheckIt.key()], color); } } itsGraphicsScene->addLine(QLineF(0, -5000, 0, 5000), QPen(QColor(128, 0, 0))); itsGraphicsScene->addLine(QLineF(0, 0, itsMaxPlotLength, 0), QPen(QColor(128, 0, 0))); itsGraphicsView->fitInView(itsGraphicsScene->itemsBoundingRect()); itsGraphicsView->ensureVisible(itsGraphicsScene->itemsBoundingRect()); itsGraphicsView->centerOn(itsMaxPlotLength/2, 0); }
QRectF Visualizer::putWord(QString word, float x, float y, bool isOnTop, int pos, QMap<int, QVector<int> > map) { QGraphicsTextItem *wordItem = new QGraphicsTextItem(QString(word)); if(selWordRef.isActive()) { if(selWordRef.isOnTop() == isOnTop) { if(selWordRef.getPos() == pos) { wordItem->setDefaultTextColor(QColor("red")); } } else { QMapIterator<int, QVector<int> > i(map); while(i.hasNext()) { i.next(); qDebug() << i.key() << " --- " << selWordRef.getPos() - 1; } QVector<int> targets = map[selWordRef.getPos() - 1]; if(targets.contains(pos)) { wordItem->setDefaultTextColor(QColor("orange")); } } } wordItem->setFont(font); wordItem->setPos(x, y); wordItem->setData(IS_ON_TOP_KEY, QVariant(isOnTop)); wordItem->setData(POS_KEY, QVariant(pos)); QRectF rect = wordItem->boundingRect(); scene->addItem(wordItem); return rect; }
void DSS::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { QGraphicsScene* scene = new QGraphicsScene; for(int i = 0; i < 25; i++) for(int j = 0; j < 25; j++) { QString id = "HDD #" + QString::number(i + i*j); HDDRank* item = new HDDRank(id, i*120, j*120, (health == Qt::red)? i*4 : 30, view, mainWindow); scene->addItem(item); } if(name == "DSS #1") { QGraphicsRectItem* t = new QGraphicsRectItem(120*16-20,-20,120*9,120*25+20); scene->addItem(t); t = new QGraphicsRectItem(-20,-20,120*16,120*25+20); scene->addItem(t); QGraphicsTextItem* txt = new QGraphicsTextItem("VolumePool 0"); txt->setPos(120*16-30, -35*5); txt->setScale(8); scene->addItem(txt); txt = new QGraphicsTextItem("VolumePool 1"); txt->setPos(-30, -35*5); txt->setScale(8); scene->addItem(txt); } else { QGraphicsTextItem* txt = new QGraphicsTextItem("VolumePool 1"); txt->setPos(-30, -35*5); txt->setScale(8); scene->addItem(txt); QGraphicsRectItem* t = new QGraphicsRectItem(-20,-20,120*25+20,120*25+20); scene->addItem(t); } scene->setSceneRect(-1500,-1500,8000,8000); mainWindow->view2->view()->setScene(scene); mainWindow->SplitScreen(); update(); }
ParticipantInfoDialog::ParticipantInfoDialog(Participant* participant, QWidget* parent, bool showRemove) : PopupDialog( parent ), m_participant(participant) { setMinimumWidth(400); setMinimumHeight(160); this->setSizeGripEnabled(false); QGraphicsPixmapItem* image = new QGraphicsPixmapItem( participant->pixmap().scaled(80, 80, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), widget() ); image->setPos( 8, 8 ); QGraphicsLineItem* line = new QGraphicsLineItem( widget() ); line->setPen( QPen( QColor( 100, 100, 100 ) ) ); line->setLine( 8, 110, width() - 2 * 8, 110 ); int buttonRight = width() - 10; QPushButton* button = new QPushButton(); button->setText(tr("New Wave")); QGraphicsProxyWidget* item = scene()->addWidget(button); item->setParentItem( widget() ); item->setPos( buttonRight - item->preferredWidth(), height() - 10 - item->preferredHeight() ); buttonRight -= item->preferredWidth() + 10; //Adds remove button if parent is a waveview if (showRemove) { QPushButton* removeFromWaveButton = new QPushButton(); removeFromWaveButton->setText(tr("Remove")); QGraphicsProxyWidget* removeItem = scene()->addWidget(removeFromWaveButton); removeItem->setParentItem( widget() ); removeItem->setPos( buttonRight - removeItem->preferredWidth(), height() - 10 - removeItem->preferredHeight() ); buttonRight -= removeItem->preferredWidth() + 10; connect( removeFromWaveButton, SIGNAL(clicked()),SLOT(removeParticipant())); } QPushButton* button2 = new QPushButton(); button2->setText(tr("Close")); QGraphicsProxyWidget* item2 = scene()->addWidget(button2); item2->setParentItem( widget() ); item2->setPos( buttonRight - item2->preferredWidth(), height() - 10 - item2->preferredHeight() ); QGraphicsTextItem* text = new QGraphicsTextItem( participant->name(), widget() ); text->setPos( 110, 10 ); text->setFont( QFont( "Arial", 18, QFont::Bold ) ); text = new QGraphicsTextItem( tr("Address") + ": " + participant->address(), widget() ); text->setPos( 110, 50 ); text->setFont( QFont( "Arial", 11 ) ); connect( button, SIGNAL(clicked()), SLOT(newWave())); connect( button2, SIGNAL(clicked()), SLOT(close())); }
QGraphicsTextItem * GraphicsButton::decorateKey(const QRectF & cell,int group,int level) { QString text = m_keydef->getDecoration(group,level); QGraphicsTextItem * item = new QGraphicsTextItem(this); int scriptCount = 0; /// Get the script for the text and use it as CSS selector /// selectors are case insensitive /// QString script; if (text.size() == 1) { script = UcdScripts::getScript(text.at(0).unicode()); if ( ! script.isEmpty()) { scriptCount = 1; } } else { script = UcdScripts::getScript(text,&scriptCount); if (scriptCount != 1) { script = "default"; } } script = script.toCaseFolded(); if (! m_css.isEmpty()) item->document()->setDefaultStyleSheet(m_css); /// this stops Arabic being moved to the right QTextOption topt; topt.setTextDirection(Qt::LeftToRight); item->document()->setDefaultTextOption(topt); QString sep("<br/>"); QString html; QStringList w = text.toHtmlEscaped().split(QChar(' '),QString::SkipEmptyParts); // QFont f("Amiri",30); // item->setFont(f); // html = QString("<html><body><span class=\"%1\">%2</span></body></html>").arg(script).arg(text); html = QString("<span class=\"%1\">%2</span>").arg(script).arg(w.join("<br/>")); item->setHtml(html);//Html(html); QRectF wr = item->boundingRect(); /// align the text centrally in its bounding rect qreal dx = cell.width() - wr.width(); qreal dy = cell.height() - wr.height(); if (m_keydef->centerText(group,level)) { dy = dy/2; } else { int vpos = m_keydef->getVerticalAdjust(group,level); dy += vpos; } item->setPos(cell.topLeft() + QPointF(dx/2,dy));//dy/2)); item->setDefaultTextColor(m_textColor); this->setBrush(QBrush(m_backgroundUpColor)); this->setPen(QPen(m_textColor)); return item; }
void dialogGridappearance::addText(qreal x, qreal y, QString text, QColor color) { QFontMetrics fm(scene->font()); QGraphicsTextItem *item; item = scene->addText(text); item->setDefaultTextColor(color); item->setPos(x,y-fm.height()*1.5); }
void StoryCardScene::initCard(qreal x, qreal y, qreal width, qreal height) { QGraphicsTextItem *pItem; QFont aFont("Arial",8); // add static scene items addRect(theDescRect); //Description pItem = addText("Notes", aFont); pItem->setPos(theNotesRect.x(), theNotesRect.y()- 2*aFont.pointSize()-2); addRect(theNotesRect); //Notes pItem = addText("How To Demo", aFont); pItem->setPos(theHTDRect.x(), theHTDRect.y()- 2*aFont.pointSize()-2); addRect(theHTDRect); //Demo aFont.setPointSize(7); pItem = addText("Importance", aFont); pItem->setPos(theImpRect.x(), theImpRect.y()- 2*aFont.pointSize()-2); addRect(theImpRect); //Importance pItem = addText("Estimation", aFont); pItem->setPos(theEstRect.x(), theEstRect.y()- 2*aFont.pointSize()-2); addRect(theEstRect); //Estimation //add variable scene items theStoryID = addText(""); theStoryID->setPos(theIDRect.x(),theIDRect.y()); theStoryID->setTextWidth(theIDRect.width()); theStoryDesc = addText(""); theStoryDesc->setPos(theDescRect.x(),theDescRect.y()); theStoryDesc->setTextWidth(theDescRect.width()); theStoryNotes = addText(""); theStoryNotes->setPos(theNotesRect.x(),theNotesRect.y()); theStoryNotes->setTextWidth(theNotesRect.width()); theStoryHTD = addText(""); theStoryHTD->setPos(theHTDRect.x(),theHTDRect.y()); theStoryHTD->setTextWidth(theHTDRect.width()); theStoryImp = addText(""); theStoryImp->setPos(theImpRect.x(),theImpRect.y()); theStoryImp->setTextWidth(theImpRect.width()); theStoryEst = addText(""); theStoryEst->setPos(theEstRect.x(),theEstRect.y()); theStoryEst->setTextWidth(theEstRect.width()); theStoryUser = addText(""); theStoryUser->setPos(theUserRect.x(),theUserRect.y()); theStoryUser->setTextWidth(theUserRect.width()); theParentStory = addText(""); theParentStory->setPos(theParentRect.x(),theParentRect.y()); theParentStory->setTextWidth(theParentRect.width()); }
void smithDialog::smithPrintText(QString t, double x, double y) //Print text t$ at position x,y on graph; font and color are preset { QFontMetrics fm(scene->font()); QGraphicsTextItem *item; item = scene->addText(t); item->setDefaultTextColor(smithMarkerColor); item->setPos(x,y); }
void ChartsView::drawText(QString text, qint16 x, qint16 y, QString style) { QGraphicsTextItem *textItem = new QGraphicsTextItem(text); textItem->setPos(x,y); textItem->setTransform(QTransform::fromScale(1,-1)); if(style.size())textItem->setHtml("<span style='"+style+"'>"+text+"</span>"); sceneCharts->addItem(textItem); }
void FadeMessage::setupScene() { QGraphicsRectItem *parent = m_scene.addRect(0, 0, 800, 600); parent->setPen(Qt::NoPen); parent->setZValue(0); QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/background.jpg")); bg->setParentItem(parent); bg->setZValue(-1); for (int i = 1; i < 5; ++i) for (int j = 2; j < 5; ++j) { QGraphicsRectItem *item = m_scene.addRect(i * 50, (j - 1) * 50, 38, 38); item->setParentItem(parent); item->setZValue(1); int hue = 12 * (i * 5 + j); item->setBrush(QColor::fromHsv(hue, 128, 128)); } QFont font; font.setPointSize(font.pointSize() * 2); font.setBold(true); QFontMetrics fontMetrics(font); int fh = fontMetrics.height(); QString sceneText = "Qt Everywhere!"; int sceneTextWidth = fontMetrics.width(sceneText); QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3); block->setPen(Qt::NoPen); block->setBrush(QColor(102, 153, 51)); QGraphicsTextItem *text = m_scene.addText(sceneText, font); text->setDefaultTextColor(Qt::white); text->setPos(50, 300); block->setZValue(2); block->hide(); text->setParentItem(block); m_message = block; m_effect = new QGraphicsColorizeEffect; m_effect->setColor(QColor(122, 193, 66)); m_effect->setStrength(0); m_effect->setEnabled(true); parent->setGraphicsEffect(m_effect); QPushButton *press = new QPushButton; press->setText(tr("Press me")); connect(press, SIGNAL(clicked()), SLOT(togglePopup())); m_scene.addWidget(press); #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) press->move(200, 210); #else press->move(300, 500); #endif }