PDA

View Full Version : QCheckBox on QDataWidgetMapper



Banjo
4th June 2008, 01:47
Hello

I am building an application using PyQt and SQLite3.

I need the equivalent of a boolean datatype which is not available in sqlite so I am using an integer field. I have a QCheckbox on my dialogue which is used to display/set the value of this field using a QDataWidgetMapper.

My question is do I need to overide data, setdata in my model so that the value of this field is displayed/stored correctly in the dialogue. At the moment I am getting what looks like html. I am assuming that is because the default delegate can't interpret the integer field correctly for the checkbox.

Thanks in advance.

aamer4yu
4th June 2008, 05:32
Inherit the model class. In that class make ur own display function. Call this function instead of the setData function.
Pseudo code -

class myModel :public someModel
{
private :
setData() ; // original setData . Redeclaring it in private will make it private.

public :
mySetData()
{
// do ur conversion
setData(); call the private method
}
};


Hope u get the idea :)

Banjo
5th June 2008, 03:09
Hello
Thanks for that. I had a bit of a closer look and found that the QTextEdit is where the html is coming from so I just upgraded and now use QPlainTextEdit.