本文整理汇总了C++中QTextTableCell::lastCursorPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableCell::lastCursorPosition方法的具体用法?C++ QTextTableCell::lastCursorPosition怎么用?C++ QTextTableCell::lastCursorPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableCell
的用法示例。
在下文中一共展示了QTextTableCell::lastCursorPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendMessage
void ChatView::appendMessage(const QString &sender, const QString &message)
{
QTextCursor cellCursor = table->cellAt(table->rows() - 1, 0).lastCursorPosition();
cellCursor.insertText(QDateTime::currentDateTime().toString("[hh:mm]"));
QTextTableCell senderCell = table->cellAt(table->rows() - 1, 1);
QTextCharFormat senderFormat;
if (sender == ownName) {
senderFormat.setFontWeight(QFont::Bold);
senderFormat.setForeground(Qt::red);
} else
senderFormat.setForeground(Qt::blue);
senderCell.setFormat(senderFormat);
cellCursor = senderCell.lastCursorPosition();
cellCursor.insertText(sender);
QTextTableCell messageCell = table->cellAt(table->rows() - 1, 2);
QTextCharFormat messageFormat;
if (sender.isEmpty())
messageFormat.setForeground(Qt::darkGreen);
messageCell.setFormat(messageFormat);
cellCursor = messageCell.lastCursorPosition();
cellCursor.insertText(message);
table->appendRows(1);
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
}
示例2: convertTable
bool Converter::convertTable(const QDomElement &element)
{
/**
* Find out dimension of the table
*/
int rowCounter = 0;
int columnCounter = 0;
QQueue<QDomNode> nodeQueue;
enqueueNodeList(nodeQueue, element.childNodes());
while (!nodeQueue.isEmpty())
{
QDomElement el = nodeQueue.dequeue().toElement();
if (el.isNull())
continue;
if (el.tagName() == QLatin1String("table-row"))
{
rowCounter++;
int counter = 0;
QDomElement columnElement = el.firstChildElement();
while (!columnElement.isNull())
{
if (columnElement.tagName() == QLatin1String("table-cell"))
{
counter++;
}
columnElement = columnElement.nextSiblingElement();
}
columnCounter = qMax(columnCounter, counter);
}
else if (el.tagName() == QLatin1String("table-header-rows"))
{
enqueueNodeList(nodeQueue, el.childNodes());
}
}
/**
* Create table
*/
QTextTable *table = m_Cursor->insertTable(rowCounter, columnCounter);
firstTime=false;
m_Cursor->movePosition(QTextCursor::End);
/**
* Fill table
*/
nodeQueue.clear();
enqueueNodeList(nodeQueue, element.childNodes());
QTextTableFormat tableFormat;
rowCounter = 0;
while (!nodeQueue.isEmpty())
{
QDomElement el = nodeQueue.dequeue().toElement();
if (el.isNull())
continue;
if (el.tagName() == QLatin1String("table-row"))
{
int columnCounter = 0;
QDomElement columnElement = el.firstChildElement();
while (!columnElement.isNull())
{
if (columnElement.tagName() == QLatin1String("table-cell"))
{
const StyleFormatProperty property = m_StyleInformation->styleProperty(columnElement.attribute("style-name"));
QTextBlockFormat format;
property.applyTableCell(&format);
QDomElement paragraphElement = columnElement.firstChildElement();
while (!paragraphElement.isNull())
{
if (paragraphElement.tagName() == QLatin1String("p"))
{
QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
// Insert a frame into the cell and work on that, so we can handle
// different parts of the cell having different block formatting
QTextCursor cellCursor = cell.lastCursorPosition();
QTextFrameFormat frameFormat;
//frameFormat.setMargin(1); // TODO: this shouldn't be hard coded
//todo: too much is created here - why?
QTextFrame *frame = cellCursor.insertFrame(frameFormat);
QTextCursor frameCursor = frame->firstCursorPosition();
frameCursor.setBlockFormat(format);
if (!convertParagraph(&frameCursor, paragraphElement, format))
return false;
}
else if (paragraphElement.tagName() == QLatin1String("list"))
{
QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
// insert a list into the cell
QTextCursor cellCursor = cell.lastCursorPosition();
if (!convertList(&cellCursor, paragraphElement))
//.........这里部分代码省略.........