PDA

View Full Version : Checkable QLineEdit ?



olidem
9th December 2009, 17:40
Hi!

I need to have a QLineEdit which has a checkbox besides (left) it.

So what I'd like is something like a QCheckBox, but instead the label, a line edit should be shown.

I already tried something like


QCheckbox * c =new QCheckBox("");
QLineEdit * le = new QLineEdit;
le->setParent(c);

But then only the line edit is shown.

Also I don't know how to handle the lineedit, when subclassing QCheckBox



class CheckableLineEdit : public QCheckBox
{
CheckableLineEdit(QWidget * p)
: QCheckBox("", p)
{
//how can I set the lineedit as "content" instead of the label?
}
}

I do not want a checkbox inside the line edit, eg. like the delete buttons (I think in wxwidgets).


Thanks in advance!
Olli

olidem
9th December 2009, 17:47
Ah, forget my question.
[done]

HBoxLayout * lay = new HBoxLayout;
lay->add(new QCheckBox)
lay->add(new QLineEdit)
QWidget * w = new QWidget;
w->setLayout(lay)