Results 1 to 2 of 2

Thread: QTextCharFormat question

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Question QTextCharFormat question

    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.

    Qt Code:
    1. bool isChecked = false;
    2. QTextCharFormat format = cursor.blockCharFormat();
    3. format.setObjectType(CheckBoxTextFormat);
    4. //CheckBox::CB_IsChecked
    5. 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

    Qt Code:
    1. // QTextCursor cursor, QTextCharFormat format are in the right position where i have my QTextObject
    2.  
    3. bool isChecked = format.property(CheckBox::CB_IsChecked).toBool();
    4. isChecked = !isChecked;
    5. format.setProperty(CheckBox::CB_IsChecked,QVariant(isChecked));
    6. cursor.beginEditBlock();
    7. cursor.mergeCharFormat(format); //for some reason this don't work
    8. cursor.cursor.setCharFormat(format); // also this don't work
    9. // when painting the QTextObjectInterface read always the same value from format.property(CheckBox::CB_IsChecked).toBool();
    10. // even if it was changed by above code.
    11. cursor.endEditBlock();
    To copy to clipboard, switch view to plain text mode 

    Is this the proper manner to do such thing ?

    Moez.
    Last edited by moez; 28th June 2010 at 10:10. Reason: spelling corrections

  2. #2
    Join Date
    Aug 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QTextCharFormat question

    Hi,

    that's very interesting for me. Heve you solved the problem?

Similar Threads

  1. QTextCharFormat::WaveUnderline doesn't work
    By roxton in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2011, 17:36
  2. QTextCharFormat and Hyperlinks
    By Rayven in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2010, 21:12
  3. QTextCharFormat::setAnchor
    By ccf_h in forum Qt Programming
    Replies: 0
    Last Post: 30th November 2008, 17:01
  4. QTextCharFormat::setAnchorNames
    By ccf_h in forum Qt Programming
    Replies: 0
    Last Post: 30th November 2008, 13:58
  5. QTextCharFormat and QVariant
    By fullmetalcoder in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2007, 11:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.