You can try doing this (didn't test it)
add this to the delegate class you already have
it does not change the apearance of the string but it will open a filedialog on edit
void ItemDelegate
::setModelData(QWidget *editor,
{
//this is for all items in the item model, if you want it only for one column check if index.column() == the column you want the filedialog for
mode.
setData(index,
QFileDialog::getOpenFileName(),Qt
::EditRole) //you need to include <QFileDialog>}
void ItemDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model, const QModelIndex &index) const
{
//this is for all items in the item model, if you want it only for one column check if index.column() == the column you want the filedialog for
mode.setData(index,QFileDialog::getOpenFileName(),Qt::EditRole) //you need to include <QFileDialog>
}
To copy to clipboard, switch view to plain text mode
if you want to change the apreance too then you need to add the special editor in your item delegate createEditor function
{
return new SpecialEditor(parent); //the special editor needs to be a QWidget or derivative from it
}
QWidget *ItemDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
return new SpecialEditor(parent); //the special editor needs to be a QWidget or derivative from it
}
To copy to clipboard, switch view to plain text mode
Bookmarks