当前位置: 首页>>代码示例>>C++>>正文


C++ ImageItem::setData方法代码示例

本文整理汇总了C++中ImageItem::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageItem::setData方法的具体用法?C++ ImageItem::setData怎么用?C++ ImageItem::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageItem的用法示例。


在下文中一共展示了ImageItem::setData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
    }
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:32,代码来源:view.cpp

示例2: 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);
     }
 }
开发者ID:rodety,项目名称:Clinica,代码行数:48,代码来源:view.cpp


注:本文中的ImageItem::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。