Hi,
I have this code as part of my Dialog with a QListView and QGraphicsView:
void TextureDialog::on_toolButtonAddLayer_clicked(){
QString fileName
= QFileDialog::getOpenFileName(this, tr
("Abrir imagen"), workingDirectory,
tr("Imagenes (*.png *.xpm *.jpg)"));
if(fileName.isEmpty()) return;
workingDirectory
=QFileInfo(fileName
).
absolutePath();
GraphicsObjectItem *objectItem=objectPreviewScene->addLayer(fileName);
StandardItem
*item
=new StandardItem
(objectItem,
QIcon(fileName
), fileName
);
qDebug()<<"objectItem: "<<objectItem<<endl<<item->sceneItem();
int row=listModelLayers->rowCount();
listModelLayers->appendRow(item);
listViewLayers->setCurrentIndex(listModelLayers->index(row, 0));
}
void TextureDialog::on_toolButtonAddLayer_clicked(){
QString fileName = QFileDialog::getOpenFileName(this, tr("Abrir imagen"), workingDirectory,
tr("Imagenes (*.png *.xpm *.jpg)"));
if(fileName.isEmpty()) return;
workingDirectory=QFileInfo(fileName).absolutePath();
GraphicsObjectItem *objectItem=objectPreviewScene->addLayer(fileName);
StandardItem *item=new StandardItem(objectItem, QIcon(fileName), fileName);
qDebug()<<"objectItem: "<<objectItem<<endl<<item->sceneItem();
int row=listModelLayers->rowCount();
listModelLayers->appendRow(item);
listViewLayers->setCurrentIndex(listModelLayers->index(row, 0));
}
To copy to clipboard, switch view to plain text mode
void TextureDialog::moveUp(){
StandardItem *item;
item=static_cast<StandardItem*>(listViewLayers->currentIndex().internalPointer());
qDebug()<<item->sceneItem();
//if(item){
//qDebug()<<item;
//}
//qDebug()<<static_cast<QObject*>(item)->objectName();
}
void TextureDialog::moveUp(){
StandardItem *item;
item=static_cast<StandardItem*>(listViewLayers->currentIndex().internalPointer());
qDebug()<<item->sceneItem();
//if(item){
//qDebug()<<item;
//}
//qDebug()<<static_cast<QObject*>(item)->objectName();
}
To copy to clipboard, switch view to plain text mode
It executes in this order, and the debug exit is:
Ejectuando...
objectItem: QGraphicsItem(this = 0x81cfe78 , parent = 0x0 , pos = QPointF( 0 , 0 ) , z = 0 , flags = { "isVisible|isEnabled" })
QGraphicsItem(this = 0x81cfe78 , parent = 0x0 , pos = QPointF( 0 , 0 ) , z = 0 , flags = { "isVisible|isEnabled" })
QGraphicsItem(0)
---------------------- Finalizado normalmente ----------------------
Someone can help me to fix this problem?
Thanks
Bookmarks