当前位置: 首页>>代码示例>>C++>>正文


C++ QTextTableCell::setFormat方法代码示例

本文整理汇总了C++中QTextTableCell::setFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableCell::setFormat方法的具体用法?C++ QTextTableCell::setFormat怎么用?C++ QTextTableCell::setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextTableCell的用法示例。


在下文中一共展示了QTextTableCell::setFormat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
开发者ID:Enoctil,项目名称:cockatrice,代码行数:26,代码来源:tab_room.cpp

示例2: fillCategoryTableLine

void PrintDialog::fillCategoryTableLine(  QTextTable * table, const unsigned int & row,
		const QString & position, const QString & lastname,
		const QString & firstname, const QString & time)
{
	int realRow = row + 1;
	table->insertRows ( realRow, 1 );

	QTextCharFormat cellFormat;
	cellFormat.setFontPointSize(10.0);
	if(row%2)
		cellFormat.setBackground(QBrush(QColor(240,240,240)));

	QTextTableCell cell = table->cellAt(realRow, 0);
	QTextCursor cursor = cell.firstCursorPosition();
	cell.setFormat(cellFormat);
	cursor.insertText(position);

	cell = table->cellAt(realRow, 1);
	cursor = cell.firstCursorPosition();
	cell.setFormat(cellFormat);
	cursor.insertText(lastname);

	cell = table->cellAt(realRow, 2);
	cursor = cell.firstCursorPosition();
	cell.setFormat(cellFormat);
	cursor.insertText(firstname);

	cell = table->cellAt(realRow, 3);
	cursor = cell.firstCursorPosition();
	cell.setFormat(cellFormat);
	cursor.insertText(time);
}
开发者ID:christarento,项目名称:ChronoDuino,代码行数:32,代码来源:PrintDialog.cpp

示例3: printDeckListNode

void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node)
{
	static const int totalColumns = 3;

	if (node->height() == 1) {
		QTextBlockFormat blockFormat;
		QTextCharFormat charFormat;
		charFormat.setFontPointSize(11);
		charFormat.setFontWeight(QFont::Bold);
		cursor->insertBlock(blockFormat, charFormat);
		cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));

		QTextTableFormat tableFormat;
		tableFormat.setCellPadding(0);
		tableFormat.setCellSpacing(0);
		tableFormat.setBorder(0);
		QTextTable *table = cursor->insertTable(node->size() + 1, 2, tableFormat);
		for (int i = 0; i < node->size(); i++) {
			AbstractDecklistCardNode *card = dynamic_cast<AbstractDecklistCardNode *>(node->at(i));

			QTextCharFormat cellCharFormat;
			cellCharFormat.setFontPointSize(9);

			QTextTableCell cell = table->cellAt(i, 0);
			cell.setFormat(cellCharFormat);
			QTextCursor cellCursor = cell.firstCursorPosition();
			cellCursor.insertText(QString("%1 ").arg(card->getNumber()));

			cell = table->cellAt(i, 1);
			cell.setFormat(cellCharFormat);
			cellCursor = cell.firstCursorPosition();
			cellCursor.insertText(card->getName());
		}
	} else if (node->height() == 2) {
		QTextBlockFormat blockFormat;
		QTextCharFormat charFormat;
		charFormat.setFontPointSize(14);
		charFormat.setFontWeight(QFont::Bold);

		cursor->insertBlock(blockFormat, charFormat);
		cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));

		QTextTableFormat tableFormat;
		tableFormat.setCellPadding(10);
		tableFormat.setCellSpacing(0);
		tableFormat.setBorder(0);
		QVector<QTextLength> constraints;
		for (int i = 0; i < totalColumns; i++)
			constraints << QTextLength(QTextLength::PercentageLength, 100.0 / totalColumns);
		tableFormat.setColumnWidthConstraints(constraints);

		QTextTable *table = cursor->insertTable(1, totalColumns, tableFormat);
		for (int i = 0; i < node->size(); i++) {
			QTextCursor cellCursor = table->cellAt(0, (i * totalColumns) / node->size()).lastCursorPosition();
			printDeckListNode(&cellCursor, dynamic_cast<InnerDecklistNode *>(node->at(i)));
		}
	}
	cursor->movePosition(QTextCursor::End);
}
开发者ID:Enoctil,项目名称:cockatrice,代码行数:59,代码来源:decklistmodel.cpp

示例4: redo

void InsertTableColumnCommand::redo()
{
    KoTableColumnAndRowStyleManager carsManager = KoTableColumnAndRowStyleManager::getManager(m_table);
    if (!m_first) {
        carsManager.insertColumns(m_column, 1, m_style);
        KUndo2Command::redo();
    } else {
        m_first = false;
        QTextTableCell cell = m_table->cellAt(*m_textEditor->cursor());
        m_column = cell.column() + (m_right ? 1 : 0);
        m_style = carsManager.columnStyle(cell.column());
        m_table->insertColumns(m_column, 1);
        carsManager.insertColumns(m_column, 1, m_style);

        if (m_right && m_column == m_table->columns()-1) {
            // Copy the cell style. for the bottomright cell which Qt doesn't
            QTextTableCell cell = m_table->cellAt(m_table->rows()-1, m_column - 1);
            QTextCharFormat format = cell.format();
            cell = m_table->cellAt(m_table->rows()-1, m_column);
            cell.setFormat(format);
        }

        if (m_changeId) {
            for (int i=0; i < m_table->rows(); i++) {
                QTextTableCellFormat cellFormat = m_table->cellAt(i, m_column).format().toTableCellFormat();
                cellFormat.setProperty(KoCharacterStyle::ChangeTrackerId, m_changeId);
                m_table->cellAt(i, m_column).setFormat(cellFormat);
            }
        }
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:31,代码来源:InsertTableColumnCommand.cpp

示例5: cursor

void
ChatDialog::appendChatMessage(const QString& nick, const QString& text, time_t timestamp)
{
  QTextCharFormat nickFormat;
  nickFormat.setForeground(Qt::darkGreen);
  nickFormat.setFontWeight(QFont::Bold);
  nickFormat.setFontUnderline(true);
  nickFormat.setUnderlineColor(Qt::gray);

  // Print who & when
  QTextCursor cursor(ui->textEdit->textCursor());
  cursor.movePosition(QTextCursor::End);
  QTextTableFormat tableFormat;
  tableFormat.setBorder(0);
  QTextTable *table = cursor.insertTable(1, 2, tableFormat);
  QString from = QString("%1 ").arg(nick);
  QTextTableCell fromCell = table->cellAt(0, 0);
  fromCell.setFormat(nickFormat);
  fromCell.firstCursorPosition().insertText(from);
  printTimeInCell(table, timestamp);

  // Print what
  QTextCursor nextCursor(ui->textEdit->textCursor());
  nextCursor.movePosition(QTextCursor::End);
  table = nextCursor.insertTable(1, 1, tableFormat);
  table->cellAt(0, 0).firstCursorPosition().insertText(text);

  // Popup notification
  showMessage(from, text);

  QScrollBar *bar = ui->textEdit->verticalScrollBar();
  bar->setValue(bar->maximum());
}
开发者ID:bruinfish,项目名称:ChronoChat,代码行数:33,代码来源:chat-dialog.cpp

示例6: featureUpdate

void MessageAction::featureUpdate()
{
    QTextTableCell cell = textTable->cellAt(0,3);
    QTextTableCellFormat format;
    if (!isProcessed)
        format.setBackground(QColor(Qt::red));
    else
        format.setBackground(QColor(Qt::white));
    cell.setFormat(format);
}
开发者ID:ACKino,项目名称:qTox,代码行数:10,代码来源:messageaction.cpp

示例7:

void
ChatDialog::printTimeInCell(QTextTable *table, time_t timestamp)
{
  QTextCharFormat timeFormat;
  timeFormat.setForeground(Qt::gray);
  timeFormat.setFontUnderline(true);
  timeFormat.setUnderlineColor(Qt::gray);
  QTextTableCell timeCell = table->cellAt(0, 1);
  timeCell.setFormat(timeFormat);
  timeCell.firstCursorPosition().insertText(formatTime(timestamp));
}
开发者ID:bruinfish,项目名称:ChronoChat,代码行数:11,代码来源:chat-dialog.cpp

示例8: sipNoMethod

static PyObject *meth_QTextTableCell_setFormat(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QTextCharFormat* a0;
        QTextTableCell *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QTextTableCell, &sipCpp, sipType_QTextCharFormat, &a0))
        {
            sipCpp->setFormat(*a0);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QTextTableCell, sipName_setFormat, doc_QTextTableCell_setFormat);

    return NULL;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:22,代码来源:sipQtGuiQTextTableCell.cpp

示例9: initTest

void TestTableLayout::initTest(int rows, int columns,
        KoTableStyle *tableStyle,
        const QList<KoTableColumnStyle *> &columnStyles,
        const QList<KoTableRowStyle *> &rowStyles,
        const QMap<QPair<int, int>, KoTableCellStyle *> &cellStyles,
        const QMap<QPair<int, int>, QString> &cellTexts)
{
    // Mock shape of size 200x1000 pt.
    m_shape = new MockTextShape();
    Q_ASSERT(m_shape);
    m_shape->setSize(QSizeF(200, 1000));

    // Document layout.
    m_layout = m_shape->layout;
    Q_ASSERT(m_layout);

    // Document.
    m_doc = m_layout->document();
    Q_ASSERT(m_doc);
    m_doc->setDefaultFont(QFont("Sans Serif", 12, QFont::Normal, false));

    // Layout state (layout helper).
    m_textLayout = new Layout(m_layout);
    Q_ASSERT(m_textLayout);
    m_layout->setLayout(m_textLayout);

    // Style manager.
    m_styleManager = new KoStyleManager();
    Q_ASSERT(m_styleManager);
    KoTextDocument(m_doc).setStyleManager(m_styleManager);

    // Table style.
    m_defaultTableStyle = new KoTableStyle();
    Q_ASSERT(m_defaultTableStyle);
    m_defaultTableStyle->setMargin(0.0);
    m_defaultTableStyle->setWidth(QTextLength(QTextLength::FixedLength, 200));
    QTextTableFormat tableFormat;
    if (tableStyle) {
        tableStyle->applyStyle(tableFormat);
    } else {
        m_defaultTableStyle->applyStyle(tableFormat);
    }

    // Table.
    QTextCursor cursor(m_doc);
    m_table = cursor.insertTable(rows, columns, tableFormat);
    Q_ASSERT(m_table);

    // Column and row style manager.
    m_tableColumnAndRowStyleManager = KoTableColumnAndRowStyleManager::getManager(m_table);

    // Column styles.
    m_defaultColumnStyle.setRelativeColumnWidth(50.0);
    for (int col = 0; col < columns; ++col) {
        if (columnStyles.value(col)) {
            m_tableColumnAndRowStyleManager.setColumnStyle(col, *(columnStyles.at(col)));
        } else {
            m_tableColumnAndRowStyleManager.setColumnStyle(col, m_defaultColumnStyle);
        }
    }

    // Row styles.
    for (int row = 0; row < rows; ++row) {
        if (rowStyles.value(row)) {
            m_tableColumnAndRowStyleManager.setRowStyle(row, *(rowStyles.at(row)));
        } else {
            m_tableColumnAndRowStyleManager.setRowStyle(row, m_defaultRowStyle);
        }
    }

    // Cell styles and texts.
    m_defaultCellStyle = new KoTableCellStyle();
    Q_ASSERT(m_defaultCellStyle);
    for (int row = 0; row < m_table->rows(); ++row) {
        for (int col = 0; col < m_table->columns(); ++col) {
            // Style.
            QTextTableCell cell = m_table->cellAt(row, col);
            QTextTableCellFormat cellFormat = cell.format().toTableCellFormat();
            if (cellStyles.contains(qMakePair(row, col))) {
                cellStyles.value(qMakePair(row, col))->applyStyle(cellFormat);
                cell.setFormat(cellFormat.toCharFormat());
            } else {
                m_defaultCellStyle->applyStyle(cellFormat);
            }
            cell.setFormat(cellFormat.toCharFormat());
            // Text.
            if (cellTexts.contains(qMakePair(row, col))) {
                cell.firstCursorPosition().insertText(cellTexts.value(qMakePair(row, col)));
            }
        }
    }
    KoParagraphStyle style;
    style.setStyleId(101); // needed to do manually since we don't use the stylemanager
    QTextBlock b2 = m_doc->begin();
    while (b2.isValid()) {
        style.applyStyle(b2);
        b2 = b2.next();
    }

}
开发者ID:KDE,项目名称:calligra-history,代码行数:100,代码来源:TestTableLayout.cpp

示例10:

QTextTable * PrintDialog::insertCategoryTable(QTextCursor & cursor, const QString & categoryName)
{
	QTextBlockFormat blockCategoryTitleFormat;
	blockCategoryTitleFormat.setAlignment(Qt::AlignCenter);
	blockCategoryTitleFormat.setTopMargin(40.0);
	blockCategoryTitleFormat.setBottomMargin(30.0);

	QTextCharFormat categoryTitleFormat;
	categoryTitleFormat.setFontCapitalization(QFont::AllUppercase);
	categoryTitleFormat.setFontWeight(25);
	categoryTitleFormat.setFontPointSize(14.0);
	QString category = "Category \"";
	category += categoryName;
	category += "\"";

	cursor.insertBlock(blockCategoryTitleFormat);
	cursor.insertText(category,categoryTitleFormat);


	cursor.insertBlock(QTextBlockFormat()); // to break the previous block format
	QTextTable * table = cursor.insertTable(1, 4);
	if(!table)
		return NULL;
	QTextTableFormat categoryTableFormat;
	categoryTableFormat.setAlignment(Qt::AlignHCenter);
	categoryTableFormat.setHeaderRowCount(1); // header line
	categoryTableFormat.setBorderStyle(QTextTableFormat::BorderStyle_Solid);
	categoryTableFormat.setBorder(1.0);
	categoryTableFormat.setCellPadding(10);
	categoryTableFormat.setCellSpacing(0);

	table->setFormat(categoryTableFormat);

	// header :
	// header cell format :
	QTextCharFormat headerCellFormat;
	headerCellFormat.setFontWeight(50);
	headerCellFormat.setFontPointSize(12.0);
	headerCellFormat.setBackground(QBrush(QColor(60,60,60)));
	headerCellFormat.setForeground(QBrush(QColor(255,255,255)));

	QTextTableCell cell = table->cellAt(0,0);
	cell.setFormat(headerCellFormat);
	cursor = cell.firstCursorPosition();
	cursor.insertText(tr("Position"));

	cell = table->cellAt(0,1);
	cell.setFormat(headerCellFormat);
	cursor = cell.firstCursorPosition();
	cursor.insertText(tr("LastName"));

	cell = table->cellAt(0,2);
	cell.setFormat(headerCellFormat);
	cursor = cell.firstCursorPosition();
	cursor.insertText(tr("Firstname"));

	cell = table->cellAt(0,3);
	cell.setFormat(headerCellFormat);
	cursor = cell.firstCursorPosition();
	cursor.insertText(tr("Time"));

	return table;
}
开发者ID:christarento,项目名称:ChronoDuino,代码行数:63,代码来源:PrintDialog.cpp


注:本文中的QTextTableCell::setFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。