here it is, the layout stuff has been commented out:
{
public:
{
//
//QVBoxLayout *p_pLayout = new QVBoxLayout();
//this->setLayout(p_pLayout);
};
~ItemEditor(void){};
virtual void setData
(QVariant &i_Data
) = 0;
};
class ItemLineEditor : public ItemEditor
{
private:
public:
ItemLineEditor
(QWidget *i_pParent
= NULL): ItemEditor
(i_pParent
) {
// without layout
//using a layout doesn't work at all
//m_pLineEdit = new QLineEdit(this);
//this->layout()->addWidget(m_pLineEdit);
}
{
return m_pLineEdit->text();
}
{
this->m_pLineEdit->setText(i_Data.toString());
}
// gets never called
virtual void setGeometry(const QRect& rect)
{
ItemEditor::setGeometry(rect);
this->m_pLineEdit->setGeometry(rect);
}
};
class ItemEditor : public QWidget
{
public:
ItemEditor(QWidget *i_pParent = NULL): QWidget(i_pParent)
{
//
//QVBoxLayout *p_pLayout = new QVBoxLayout();
//this->setLayout(p_pLayout);
};
~ItemEditor(void){};
virtual QVariant data() = 0;
virtual void setData(QVariant &i_Data) = 0;
};
class ItemLineEditor : public ItemEditor
{
private:
QLineEdit *m_pLineEdit;
public:
ItemLineEditor(QWidget *i_pParent = NULL): ItemEditor(i_pParent)
{
// without layout
m_pLineEdit = new QLineEdit(this);
//using a layout doesn't work at all
//m_pLineEdit = new QLineEdit(this);
//this->layout()->addWidget(m_pLineEdit);
}
virtual QVariant data()
{
return m_pLineEdit->text();
}
virtual void setData(QVariant &i_Data)
{
this->m_pLineEdit->setText(i_Data.toString());
}
// gets never called
virtual void setGeometry(const QRect& rect)
{
ItemEditor::setGeometry(rect);
this->m_pLineEdit->setGeometry(rect);
}
};
To copy to clipboard, switch view to plain text mode
as you may see, i'm doing this because i need a unified way of accessing the user input from different widgets (combobox, doublespinbox, lineedit etc.)
Bookmarks