thanks
i have this.
in header :
namespace Ui {
class DodajWplate;
class LineEditDelegate;
}
class DodajWplate
: public QDialog { ...
};
{
Q_OBJECT
public:
LineEditDelegate
(QObject* parent
= 0);
QWidget* createEditor
(QWidget *parent,
const QStyleOptionViewItem
& option,
const QModelIndex
& index
) const;
void setEditorData
(QWidget* editor,
const QModelIndex
& index
) const;
};
namespace Ui {
class DodajWplate;
class LineEditDelegate;
}
class DodajWplate : public QDialog {
...
};
class LineEditDelegate : public QItemDelegate
{
Q_OBJECT
public:
LineEditDelegate(QObject* parent = 0);
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
void setEditorData(QWidget* editor, const QModelIndex& index) const;
};
To copy to clipboard, switch view to plain text mode
in cpp :
QWidget* LineEditDelegate
::createEditor(QWidget* parent,
const QStyleOptionViewItem
&,
const QModelIndex
&) const {
return lewtv;
}
void LineEditDelegate
::setEditorData(QWidget* editor,
const QModelIndex
& index
) const {
QString value
= index.
model()->data
(index, Qt
::EditRole).
toString();
QLineEdit* lewtv
= static_cast<QLineEdit
*>
(editor
);
lewtv->setText(value);
}
QWidget* LineEditDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const
{
QLineEdit* lewtv = new QLineEdit(parent);
return lewtv;
}
void LineEditDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
QString value = index.model()->data(index, Qt::EditRole).toString();
QLineEdit* lewtv = static_cast<QLineEdit*>(editor);
lewtv->setText(value);
}
To copy to clipboard, switch view to plain text mode
and
ui->tableView->setItemDelegateForColumn(2, new LineEditDelegate);
ui->tableView->setItemDelegateForColumn(2, new LineEditDelegate);
To copy to clipboard, switch view to plain text mode
When i want to build i have error :
undefined reference to `LineEditDelegate::LineEditDelegate(QObject*)'
Bookmarks