Hi,
This is a question for experimented qt scribe classes programmers.
I am trying to simulate check box widget inside my rich text.
so i have created a QTextObjectInterface that paint this 'check box' for me. I do store the 'check state' inside the a custom QTextChartFormat created for with this interface.
bool isChecked = false;
format.setObjectType(CheckBoxTextFormat);
//CheckBox::CB_IsChecked
format.setProperty(CheckBox::CB_IsChecked,isChecked);
bool isChecked = false;
QTextCharFormat format = cursor.blockCharFormat();
format.setObjectType(CheckBoxTextFormat);
//CheckBox::CB_IsChecked
format.setProperty(CheckBox::CB_IsChecked,isChecked);
To copy to clipboard, switch view to plain text mode
When user click the 'checkbox' i do call this code to simulate a click
// QTextCursor cursor, QTextCharFormat format are in the right position where i have my QTextObject
bool isChecked = format.property(CheckBox::CB_IsChecked).toBool();
isChecked = !isChecked;
format.
setProperty(CheckBox
::CB_IsChecked,
QVariant(isChecked
));
cursor.beginEditBlock();
cursor.mergeCharFormat(format); //for some reason this don't work
cursor.cursor.setCharFormat(format); // also this don't work
// when painting the QTextObjectInterface read always the same value from format.property(CheckBox::CB_IsChecked).toBool();
// even if it was changed by above code.
cursor.endEditBlock();
// QTextCursor cursor, QTextCharFormat format are in the right position where i have my QTextObject
bool isChecked = format.property(CheckBox::CB_IsChecked).toBool();
isChecked = !isChecked;
format.setProperty(CheckBox::CB_IsChecked,QVariant(isChecked));
cursor.beginEditBlock();
cursor.mergeCharFormat(format); //for some reason this don't work
cursor.cursor.setCharFormat(format); // also this don't work
// when painting the QTextObjectInterface read always the same value from format.property(CheckBox::CB_IsChecked).toBool();
// even if it was changed by above code.
cursor.endEditBlock();
To copy to clipboard, switch view to plain text mode
Is this the proper manner to do such thing ?
Moez.
Bookmarks