I use a QTreeView to visualize my objects properties. Its something like the Property Editor in the Qt Designer. I have every kind of values, bool, text, color values, enum, float, int, filenames etc.
I use a coustom model for holding all the object values and display it via a coustom delegate. So the delegate detects the kind of data and have special representation for editing, e.g. Spinboxes for int/float, and checkboxes for bool. At the moment my Delegate creates editor for eg spinboxes AND override the paint() function for representing a value as checkbox.
Now i want to allow the user to edit a value in two ways. The user should use a normal textfield for edting, copy/paste, etc. to change the value or press a button for open the QFileDialog and select the correct file.
It should look like this picture:
How can i achieve this?
I need a textfield AND a button to open the QFileDialog.
I use Qt 5.0. Thx for help
You'd have to use a custom widget, you could create one in code like this in your delegate's createEditor()
function/ Something along these lines:
QFrame *frame = new QFrame();
frame->setLayout( new QHBoxLayout() );
frame->layout()->addWidget( new QLineEdit() );
frame->layout()->addWidget( new QToolButton() );
return frame;
Or you could create a custom widget with designer and return one of those.