I have a column in my table view that holds links to either an online PDF, or a local one. The default editor is fine for just adding web links, but more troublesome for adding a file path. I made a dialog where the user can paste a web link, or open a QFileDialog to get the path. I currently have, in createEditor()
else if(header == "Datasheet")
{
AddPDFDialog *dialog = new AddPDFDialog(parent);
connect(dialog,
SIGNAL(pdfAdded
(QString)),
dialog->exec();
model->setData(index, path);
return QStyledItemDelegate::createEditor(parent, option, index);
}
else if(header == "Datasheet")
{
AddPDFDialog *dialog = new AddPDFDialog(parent);
connect(dialog, SIGNAL(pdfAdded(QString)),
this, SLOT(addPDF(QString)));
dialog->exec();
model->setData(index, path);
return QStyledItemDelegate::createEditor(parent, option, index);
}
To copy to clipboard, switch view to plain text mode
and use
void CompleterDelegate
::addPDF(QString path
) {
this->path = path;
}
void CompleterDelegate::addPDF(QString path)
{
this->path = path;
}
To copy to clipboard, switch view to plain text mode
to catch the slot. this->path is a public QString.
It works fine, so far, but it seems like sort of a hack creating the variable. Is there a way to access the slot, directly, inside of createEditor()?
Bookmarks