Results 1 to 2 of 2

Thread: QTextCursor Find QTextTable ok and !QTextImageFormat

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextCursor Find QTextTable ok and !QTextImageFormat

    I build a small xhtml editor.... start point is QTextEdit

    to discovery the objekt QTextTable is easy and i can make context menu to chance cellpadding spacing background color widht and so....

    QTextTable * QTextCursor::currentTable () const
    Returns a pointer to the current table if the cursor position() is inside a block that is part of a table; otherwise returns 0.



    Now i like to discovery QTextImageFormat objekt to chance hight widht name ... how i find a pointer ?...


    Qt Code:
    1. /* QTextEdit *html_area; */
    2. connect(html_area, SIGNAL(cursorPositionChanged()),this , SLOT(WakeUpCursor()));
    3.  
    4. void Html_Editor::WakeUpCursor()
    5. {
    6. QTextCursor findercursor(html_area->textCursor());
    7. if (!findercursor.isNull()) {
    8. /* discovery if a table is selected to display CustomContextMenu start */
    9. if (findercursor.currentTable()) { /* !=0 */
    10. worktable = true;
    11. existingtable = findercursor.currentTable(); /* (header) QTextTable *existingtable; */
    12. SetupTable();
    13. html_area->setContextMenuPolicy( Qt::CustomContextMenu );
    14. connect(html_area , SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
    15. } else {
    16. ResetTableContex(); /* disconnect remove table context menu and work table false */
    17. }
    18. /* discovery if a table is selected to display CustomContextMenu end */
    19.  
    20. /* discovery?? #include <QTextImageFormat>*/
    21. }
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextCursor Find QTextTable ok and !QTextImageFormat

    I found selft the pointer to QTextImageFormat :-) hurra!!

    Qt Code:
    1. void Html_Editor::WakeUpCursor()
    2. {
    3. QTextCursor findercursor(html_area->textCursor());
    4. if (!findercursor.isNull()) {
    5. /* discovery if a table is selected to display CustomContextMenu start */
    6. if (findercursor.currentTable()) { /* !=0 */
    7. worktable = true;
    8. existingtable = findercursor.currentTable(); /* (header) QTextTable *existingtable; */
    9. SetupTable();
    10. html_area->setContextMenuPolicy( Qt::CustomContextMenu );
    11. connect(html_area , SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
    12. } else {
    13. ResetTableContex(); /* disconnect remove table context menu and work table false */
    14. }
    15. /* discovery if a table is selected to display CustomContextMenu end */
    16. /* discovery ImageFormat selected to display CustomContextMenu start */
    17. if (findercursor.currentFrame()) {
    18. /* toImageFormat () */
    19. /* blockpiece = findercursor.currentFrame(); QTextFrame *blockpiece; */
    20. QTextImageFormat newImageFormat = findercursor.charFormat().toImageFormat();
    21. if (newImageFormat.isValid()) {
    22. qDebug() << "### QTextImageFormat YES ";
    23. } else {
    24. qDebug() << "### QTextImageFormat NO ";
    25. }
    26.  
    27. }
    28. /* discovery ImageFormat selected to display CustomContextMenu end */
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

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.