本文整理汇总了C++中ImageItem::setPos方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem::setPos方法的具体用法?C++ ImageItem::setPos怎么用?C++ ImageItem::setPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageItem
的用法示例。
在下文中一共展示了ImageItem::setPos方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDirectory
void MainWindow::setDirectory(const QString &path)
{
QDir dir(path);
QStringList files = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
foreach(const QString &file, files) {
QImageReader img(path + QLatin1String("/")+file);
QImage image = img.read();
if (!image.isNull()) {
{
ImageItem *item = new ImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
standardGestures->scene->addItem(item);
}
{
ImageItem *item = new ImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
globalViewGestures->scene->addItem(item);
}
{
GestureImageItem *item = new GestureImageItem(image);
item->setPos(0, 0);
item->setFlags(QGraphicsItem::ItemIsMovable);
graphicsItemGestures->scene->addItem(item);
}
}
}
示例2: addItems
//! [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);
}
}
示例3: addItems
void View::addItems()
{
int imageOffset = 140;
int leftMargin = 40;
int topMargin = 40;
if(comportamiento == 0)
{
query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk IS NULL)");
qDebug()<<"Entro a NULL"<<endl;
}
else
{
query.prepare("select imagen_pk from e_imagen where (url = '"+carpeta+"' and reporte_operatorio_pk = '"+documento+"')");
qDebug()<<"Entro a "<<documento<<endl;
//qDebug("select imagen_pk from e_imagen where (url = '"+carpeta.toStdString()+"' and reporte_operatorio_pk = '"+documento.toStdString()+"')");
}
int i = 0;
query.exec();
while(query.next())
{
QGraphicsTextItem *label = new QGraphicsTextItem;
int id = query.value(0).toInt();
QString file = query.value(0).toString()+".JPG";
qDebug()<<"Agregando al visor"<<file<<endl;
QFileInfo fileInfo(file);
//fecha de creacion de archivo
QString location = fileInfo.created().toString();
int columnOffset = ((i / 3) * 37);
int x = ((i / 3) * imageOffset) + leftMargin + columnOffset;
int y = ((i % 3) * imageOffset) + topMargin;
ImageItem *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);
i++;
//Guardando los punteros para luego eliminarlos;
QPair<QGraphicsTextItem*, ImageItem*> par_punteros;
par_punteros.first = label;
par_punteros.second = image;
punteros.push_back(par_punteros);
}
}
示例4: setIndex
void BlurPicker::setIndex(qreal index)
{
m_index = index;
qreal baseline = 0;
for (int i = 0; i < m_icons.count(); ++i) {
ImageItem *icon = m_icons[i];
qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count();
qreal xs = 380 * qSin(a);
qreal ys = 230 * qCos(a);
QPointF pos(xs, ys);
// pos = QTransform::scale(0,0.2).map(pos);
// pos = QTransform().rotate(-20).map(pos);
pos = QTransform().rotate(-5).map(pos);
pos -= QPointF(40, 40);
// pos -= QPoint(10,10);
icon->setPos(pos);
baseline = qMax(baseline, ys);
static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline);
}
scene()->update();
}
示例5: on_filesTable_currentCellChanged
void MainWindow::on_filesTable_currentCellChanged(int currentRow, int /*currentColumn*/, int /*previousRow*/, int /*previousColumn*/)
{
ui->stackedWidget->setCurrentWidget(ui->emptyPage);
QString resourceName = ui->filesTable->item(currentRow, 0)->text();
QRectF boundingBox;
m_scene.clear();
if(resourceName.endsWith(".pcx")) {
ImageItem *item = new ImageItem(readPCXimage(resourceName));
m_scene.addItem(item);
boundingBox = item->boundingRect();
ui->stackedWidget->setCurrentWidget(ui->graphicsPage);
}
if(resourceName.endsWith(".gob")) {
std::vector<GobImage> gobImages = m_resourceContainer.readGOB( resourceName.toStdString() );
QPointF coordinates;
for(const GobImage &gobImage : gobImages) {
ImageItem *item = new ImageItem(readGobImage(gobImage));
m_scene.addItem(item);
item->setPos(coordinates);
coordinates.rx() += gobImage.width() + 2;
QRectF itemBB = item->mapToScene(item->boundingRect()).boundingRect();
boundingBox.setRight( qMax( boundingBox.right(), itemBB.right() ) );
boundingBox.setBottom( qMax( boundingBox.bottom(), item->boundingRect().bottom() ) );
m_scene.addRect(itemBB, QPen(QColor(127, 127, 127, 200)));
}
ui->stackedWidget->setCurrentWidget(ui->graphicsPage);
}
if(resourceName == "levelmap.txt") {
ImageItem *item = new ImageItem(readPCXimage("level.pcx"));
m_scene.addItem(item);
boundingBox = item->boundingRect();
std::vector<char> entryData = m_resourceContainer.readLevel( resourceName.toStdString() );
std::vector<char>::size_type index = 0;
for(int row = 0; row < 16; row++) {
for(int column = 0; column < 22; column++) {
QColor blockColor;
switch( entryData[index] ) {
case '0':
blockColor.setRgb(0, 0, 0, 0);
break;
case '1':
blockColor.setRgb(200, 100, 0, 200);
break;
case '2':
blockColor.setRgb(0, 60, 85, 200);
break;
case '3':
blockColor.setRgb(140, 220, 255, 200);
break;
case '4':
blockColor.setRgb(200, 200, 0, 200);
break;
default:
blockColor.setRgb(200, 0, 0, 200);
}
QPen pen;
pen.setWidth(0);
m_scene.addRect(QRect(column * 16, row * 16, 16, 16), QPen(pen), QBrush(blockColor));
index++;
}
index += 2; // Skip "\r\n" at the end of line;
}
ui->stackedWidget->setCurrentWidget(ui->graphicsPage);
}
m_scene.setSceneRect(boundingBox);
ui->graphicsView->setZoom(1.0);
ui->graphicsView->centerOn(boundingBox.center());
if(resourceName.endsWith(".smp")) {
ui->stackedWidget->setCurrentWidget(ui->soundPage);
ui->soundPage->setSoundData(readSMP(resourceName));
ui->soundPage->setSoundDescription("Raw 8 bit signed 22050Hz");
}
if(resourceName.endsWith(".mod")) {
ui->stackedWidget->setCurrentWidget(ui->musicPage);
ui->musicPage->setMusicData(readMOD(resourceName));
}
}