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


C++ QTextTable类代码示例

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


在下文中一共展示了QTextTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: Py_INCREF

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

    {
        int a0;
        int a1;
        QTextTable *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bii", &sipSelf, sipType_QTextTable, &sipCpp, &a0, &a1))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->removeColumns(a0,a1);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QTextTable, sipName_removeColumns, doc_QTextTable_removeColumns);

    return NULL;
}
开发者ID:kunwijik,项目名称:Spectroscopy_paper,代码行数:25,代码来源:sipQtGuiQTextTable.cpp

示例3: cursor

void ChatWindow::writeMessage(MessType type, QString mess )
{
  if( mess.isEmpty() ){
    return;
  }
  
  QTextCursor cursor( m_chatEdit->textCursor() );
  cursor.movePosition(QTextCursor::End);
  QTextTable* table = cursor.insertTable(1, 2, *m_tableFormat );
  QTextCharFormat charFormat;
  
  switch( type ){
    case MyMess :
      charFormat.setForeground(Qt::blue);
      table->cellAt(0,0).firstCursorPosition().insertText("<" + m_myName + "> ", charFormat);
      table->cellAt(0,1).firstCursorPosition().insertText(mess);
      break;
    case ConMess :
      charFormat.setForeground(Qt::darkGreen);
      table->cellAt(0,0).firstCursorPosition().insertText("<" + m_conName + "> ", charFormat);
      table->cellAt(0,1).firstCursorPosition().insertText(mess);
      break;
    case StatusMess :     
      charFormat.setForeground(Qt::darkRed);
      cursor.insertText(" *** " + mess + " *** ", charFormat);
      break;
    default :
      kWarning() << "Wrong MessType";
      break;
  }
  QScrollBar *bar = m_chatEdit->verticalScrollBar();
  bar->setValue(bar->maximum());
}
开发者ID:Fxrh,项目名称:KLan,代码行数:33,代码来源:chatwindow.cpp

示例4: fillFrameIterator

void TextDocumentModel::fillFrameIterator(const QTextFrame::iterator &it, QStandardItem *parent)
{
    if (QTextFrame *frame = it.currentFrame()) {
        const QRectF b = m_document->documentLayout()->frameBoundingRect(frame);
        QTextTable *table = qobject_cast<QTextTable *>(frame);
        auto item = new QStandardItem;
        if (table) {
            item->setText(tr("Table"));
            appendRow(parent, item, table->format(), b);
            fillTable(table, item);
        } else {
            item->setText(tr("Frame"));
            appendRow(parent, item, frame->frameFormat(), b);
            fillFrame(frame, item);
        }
    }
    const QTextBlock block = it.currentBlock();
    if (block.isValid()) {
        auto item = new QStandardItem;
        item->setText(tr("Block: %1").arg(block.text()));
        const QRectF b = m_document->documentLayout()->blockBoundingRect(block);
        appendRow(parent, item, block.blockFormat(), b);
        fillBlock(block, item);
    }
}
开发者ID:KDAB,项目名称:GammaRay,代码行数:25,代码来源:textdocumentmodel.cpp

示例5: if

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

示例6: sl_MergeCellsAction_Triggered

void TextEditWidget::sl_MergeCellsAction_Triggered() {
	QTextTable* table = textField->textCursor().currentTable();
	if (!table) {
		WARNING("Wrong button state");
		return;
	}

	table->mergeCells(textField->textCursor());
}
开发者ID:WalterSullivan,项目名称:qNotesManager,代码行数:9,代码来源:texteditwidget.cpp

示例7: sl_RemoveColumnAction_Triggered

void TextEditWidget::sl_RemoveColumnAction_Triggered() {
	QTextTable* table = textField->textCursor().currentTable();
	if (!table) {
		WARNING("Wrong button state");
		return;
	}

	int columnNumber = table->cellAt(textField->textCursor()).column();
	table->removeColumns(columnNumber, 1);
}
开发者ID:WalterSullivan,项目名称:qNotesManager,代码行数:10,代码来源:texteditwidget.cpp

示例8: cursor

void MyChat::appendMessage(const QString from, const QString message)
{
    QTextCursor cursor(textEdit->textCursor());
    cursor.movePosition(QTextCursor::End);
    QTextTable *table = cursor.insertTable(1, 2, tableFormat);
    table->cellAt(0, 0).firstCursorPosition().insertText('<' + from + ">: ");
    table->cellAt(0, 1).firstCursorPosition().insertText(message);
    QScrollBar *bar = textEdit->verticalScrollBar();
    bar->setValue(bar->maximum());
}
开发者ID:sslavian812,项目名称:cpp,代码行数:10,代码来源:mychat.cpp

示例9: cursor

void Dialog_report::buat_table()
{
    int i;
    QTextCursor cursor( ui->edit->textCursor());
    cursor.movePosition(QTextCursor::Start);

    ui->edit->setText("Ini report");
    /*
    QTextTableFormat format;
    format.setHeight( 600 );
    format.setWidth( 800 );
    format.setCellPadding( 1 );
    format.setCellSpacing( 1 );
    format.setHeaderRowCount( 2 );

    QTextTable *table = cursor.insertTable(10, 5, format);
    */
    QTextTable *table = cursor.insertTable(10, 5 );


    QTextBlockFormat centerAlignment;
    centerAlignment.setAlignment(Qt::AlignHCenter);
    centerAlignment.setLineHeight( 30, QTextBlockFormat::FixedHeight);
    centerAlignment.setLeftMargin( 10 );
    centerAlignment.setRightMargin( 10 );
    QTextCursor cursor2;

    cursor2 = table->cellAt(0, 0).firstCursorPosition();
    cursor2.insertText(QString::fromUtf8("No"));
    cursor2.setBlockFormat(centerAlignment);

    for (i=1; i<9; i++)
    {

        cursor2 = table->cellAt(i, 0).firstCursorPosition();
        cursor2.setBlockFormat(centerAlignment);
        cursor2.insertText(QString::number(i+1) + "Sil");

    }



    /*
    int i, y;
    for (i=0; i<4; i++)
    {
        for (y=0;y<5; y++)
         QTextTable *table = cursor.insertTable( y, i );
            //QTextTable *table = cursor.insertTable( y, i, tableFormat);
    }*/

    //QTextTable *tbl;
    //tbl = new QTextTable( ui->edit );

}
开发者ID:anomtria,项目名称:getaran_syahdu,代码行数:55,代码来源:dialog_report.cpp

示例10: WARNING

void TextEditWidget::sl_InsertColumnAction_Triggered() {
	QTextTable* table = textField->textCursor().currentTable();
	if (!table) {
		WARNING("Wrong button state");
		return;
	}

	QTextTableCell currentCell = table->cellAt(textField->textCursor());
	table->insertColumns(currentCell.column() + 1, 1);
	QTextTableCell cell = table->cellAt(0, currentCell.column() + 1);
	textField->setTextCursor(cell.firstCursorPosition());
}
开发者ID:WalterSullivan,项目名称:qNotesManager,代码行数:12,代码来源:texteditwidget.cpp

示例11: testFindingTables

    void testFindingTables()
    {
        // How to find all the tables in a QTextDocument?
        QTextDocument textDoc;
        QTextCursor c( &textDoc );
        QTextTable* firstTable = c.insertTable( 2, 2 );
        QTextTableCell bottomRight = firstTable->cellAt( 1, 1 );
        QTextTable* secondTable = bottomRight.firstCursorPosition().insertTable( 3, 3 ); // a nested table
        c.movePosition( QTextCursor::End );
        QTextTable* thirdTable = c.insertTable( 1, 1 );
        thirdTable->firstCursorPosition().insertText( "in table" );
        c.insertText( "Foo" );
        QList<QTextTable *> origTables;
        origTables << firstTable << secondTable << thirdTable;

        // A generic and slow solution is
        //    curs.currentTable() && !tablesFound.contains(curs.currentTable())
        // for each cursor position. Surely there's better.
        // We could jump to currentFrame().lastCursorPosition() but then it would skip
        // nested tables.
        QTextDocument* clonedDoc = textDoc.clone();
        QSet<QTextTable *> tablesFound;
        {
            QTextCursor curs(clonedDoc);
            while (!curs.atEnd()) {
                QTextTable* currentTable = curs.currentTable();
                if ( currentTable && !tablesFound.contains(currentTable) ) {
                    tablesFound.insert( currentTable );
                }
                curs.movePosition( QTextCursor::NextCharacter );
            }
            QCOMPARE( tablesFound.size(), 3 );
        }

        // Let's do something else then, let's find them by cursor position
        QList<QTextTable *> tablesByPos;
        {
            // first test
            const int firstPos = firstTable->firstCursorPosition().position();
            QTextCursor curs( clonedDoc );
            curs.setPosition( firstPos );
            QVERIFY( curs.currentTable() );

            // generic loop. works this approach is in TextDocument::breakTables now.
            Q_FOREACH( QTextTable* origTable, origTables ) {
                QTextCursor curs( clonedDoc );
                curs.setPosition( origTable->firstCursorPosition().position() );
                tablesByPos.append( curs.currentTable() );
            }
            QCOMPARE( tablesByPos.size(), 3 );
            QCOMPARE( tablesByPos.toSet(), tablesFound );
        }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例12: cursor

void ChatDialog::appendMessage(const QString &from, const QString &message)
{
    if (from.isEmpty() || message.isEmpty())
        return;

    QTextCursor cursor(textEdit->textCursor());
    cursor.movePosition(QTextCursor::End);
    QTextTable *table = cursor.insertTable(1, 2, tableFormat);
    table->cellAt(0, 0).firstCursorPosition().insertText("<" + from + "> ");
    table->cellAt(0, 1).firstCursorPosition().insertText(message);
    QScrollBar *bar = textEdit->verticalScrollBar();
    bar->setValue(bar->maximum());
}
开发者ID:dfizban,项目名称:remixos-usb-tool,代码行数:13,代码来源:chatdialog.cpp

示例13: cursor

// Добавление строк в таблицу
void TableFormatter::onTableAddRowClicked(void)
{
  QTextCursor cursor(textArea->textCursor());
  QTextTable *table = cursor.currentTable();
  if(table)
  {
    QTextTableCell cell=table->cellAt(cursor); // Выясняется текущая ячейка
    int cellRowCursor=cell.row(); // Текущий номер строки (счет с нуля)

    bool ok=false;
    int addNum=QInputDialog::getInt(editor, tr("Append rows to table"),tr("Append rows:"), 1, 1, 100, 1, &ok);

    if(ok && addNum > 0)
      table->insertRows(cellRowCursor + 1,addNum);
  }
}
开发者ID:xintrea,项目名称:mytetra_dev,代码行数:17,代码来源:TableFormatter.cpp

示例14: cursor

void DashboardWindow::printTreeWidget(QPrinter *printer) {
	//build a table
    QTextDocument doc;
	QTextCursor cursor(&doc);
	QTextTable *table = cursor.insertTable(1, ui.treeWidget->columnCount());
	
	//header
	for (int colNum = 0; colNum < ui.treeWidget->columnCount(); ++colNum) {
		table->cellAt(0, colNum).firstCursorPosition().insertText(ui.treeWidget->headerItem()->text(colNum));
	}
	
	//table content
	treeWidgetToTextTable(ui.treeWidget->invisibleRootItem(), table, 1);
	
	doc.print(printer);
}
开发者ID:jhjonathanlee,项目名称:DataVis-Orange,代码行数:16,代码来源:DashboardWindow.cpp

示例15: addBorder

void QQuickTextNodeEngine::addFrameDecorations(QTextDocument *document, QTextFrame *frame)
{
    QTextDocumentLayout *documentLayout = qobject_cast<QTextDocumentLayout *>(document->documentLayout());
    QTextFrameFormat frameFormat = frame->format().toFrameFormat();

    QTextTable *table = qobject_cast<QTextTable *>(frame);
    QRectF boundingRect = table == 0
            ? documentLayout->frameBoundingRect(frame)
            : documentLayout->tableBoundingRect(table);

    QBrush bg = frame->frameFormat().background();
    if (bg.style() != Qt::NoBrush)
        m_backgrounds.append(qMakePair(boundingRect, bg.color()));

    if (!frameFormat.hasProperty(QTextFormat::FrameBorder))
        return;

    qreal borderWidth = frameFormat.border();
    if (qFuzzyIsNull(borderWidth))
        return;

    QBrush borderBrush = frameFormat.borderBrush();
    QTextFrameFormat::BorderStyle borderStyle = frameFormat.borderStyle();
    if (borderStyle == QTextFrameFormat::BorderStyle_None)
        return;

    addBorder(boundingRect.adjusted(frameFormat.leftMargin(), frameFormat.topMargin(),
                                    -frameFormat.rightMargin(), -frameFormat.bottomMargin()),
              borderWidth, borderStyle, borderBrush);
    if (table != 0) {
        int rows = table->rows();
        int columns = table->columns();

        for (int row=0; row<rows; ++row) {
            for (int column=0; column<columns; ++column) {
                QTextTableCell cell = table->cellAt(row, column);

                QRectF cellRect = documentLayout->tableCellBoundingRect(table, cell);
                addBorder(cellRect.adjusted(-borderWidth, -borderWidth, 0, 0), borderWidth,
                          borderStyle, borderBrush);
            }
        }
    }
}
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:44,代码来源:qquicktextnodeengine.cpp


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