PDA

View Full Version : QTextCursor Find QTextTable ok and !QTextImageFormat



patrik08
12th September 2006, 15:59
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 ?...




/* QTextEdit *html_area; */
connect(html_area, SIGNAL(cursorPositionChanged()),this , SLOT(WakeUpCursor()));

void Html_Editor::WakeUpCursor()
{
QTextCursor findercursor(html_area->textCursor());
if (!findercursor.isNull()) {
/* discovery if a table is selected to display CustomContextMenu start */
if (findercursor.currentTable()) { /* !=0 */
worktable = true;
existingtable = findercursor.currentTable(); /* (header) QTextTable *existingtable; */
SetupTable();
html_area->setContextMenuPolicy( Qt::CustomContextMenu );
connect(html_area , SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
} else {
ResetTableContex(); /* disconnect remove table context menu and work table false */
}
/* discovery if a table is selected to display CustomContextMenu end */

/* discovery?? #include <QTextImageFormat>*/
}

}

patrik08
12th September 2006, 17:29
I found selft the pointer to QTextImageFormat :-) hurra!!



void Html_Editor::WakeUpCursor()
{
QTextCursor findercursor(html_area->textCursor());
if (!findercursor.isNull()) {
/* discovery if a table is selected to display CustomContextMenu start */
if (findercursor.currentTable()) { /* !=0 */
worktable = true;
existingtable = findercursor.currentTable(); /* (header) QTextTable *existingtable; */
SetupTable();
html_area->setContextMenuPolicy( Qt::CustomContextMenu );
connect(html_area , SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( TableContexMenu() ) );
} else {
ResetTableContex(); /* disconnect remove table context menu and work table false */
}
/* discovery if a table is selected to display CustomContextMenu end */
/* discovery ImageFormat selected to display CustomContextMenu start */
if (findercursor.currentFrame()) {
/* toImageFormat () */
/* blockpiece = findercursor.currentFrame(); QTextFrame *blockpiece; */
QTextImageFormat newImageFormat = findercursor.charFormat().toImageFormat();
if (newImageFormat.isValid()) {
qDebug() << "### QTextImageFormat YES ";
} else {
qDebug() << "### QTextImageFormat NO ";
}

}
/* discovery ImageFormat selected to display CustomContextMenu end */
}
}