本文整理汇总了C++中QTextTable::insertRows方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTable::insertRows方法的具体用法?C++ QTextTable::insertRows怎么用?C++ QTextTable::insertRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTable
的用法示例。
在下文中一共展示了QTextTable::insertRows方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sipNoMethod
static PyObject *meth_QTextTable_insertRows(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->insertRows(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_insertRows, doc_QTextTable_insertRows);
return NULL;
}
示例2: sl_InsertRowAction_Triggered
void TextEditWidget::sl_InsertRowAction_Triggered() {
QTextTable* table = textField->textCursor().currentTable();
if (!table) {
WARNING("Wrong button state");
return;
}
QTextTableCell currentCell = table->cellAt(textField->textCursor());
table->insertRows(currentCell.row() + 1, 1);
QTextTableCell cell = table->cellAt(currentCell.row() + 1, 0);
textField->setTextCursor(cell.firstCursorPosition());
}
示例3: onTableAddRowClicked
// Добавление строк в таблицу
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);
}
}
示例4: insertCalendar
//! [5]
void MainWindow::insertCalendar()
{
editor->clear();
QTextCursor cursor = editor->textCursor();
cursor.beginEditBlock();
QDate date(selectedDate.year(), selectedDate.month(), 1);
//! [5]
//! [6]
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setBackground(QColor("#e0e0e0"));
tableFormat.setCellPadding(2);
tableFormat.setCellSpacing(4);
//! [6] //! [7]
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14);
tableFormat.setColumnWidthConstraints(constraints);
//! [7]
//! [8]
QTextTable *table = cursor.insertTable(1, 7, tableFormat);
//! [8]
//! [9]
QTextFrame *frame = cursor.currentFrame();
QTextFrameFormat frameFormat = frame->frameFormat();
frameFormat.setBorder(1);
frame->setFrameFormat(frameFormat);
//! [9]
//! [10]
QTextCharFormat format = cursor.charFormat();
format.setFontPointSize(fontSize);
QTextCharFormat boldFormat = format;
boldFormat.setFontWeight(QFont::Bold);
QTextCharFormat highlightedFormat = boldFormat;
highlightedFormat.setBackground(Qt::yellow);
//! [10]
//! [11]
for (int weekDay = 1; weekDay <= 7; ++weekDay) {
QTextTableCell cell = table->cellAt(0, weekDay-1);
//! [11] //! [12]
QTextCursor cellCursor = cell.firstCursorPosition();
cellCursor.insertText(QString("%1").arg(QDate::longDayName(weekDay)),
boldFormat);
}
//! [12]
//! [13]
table->insertRows(table->rows(), 1);
//! [13]
while (date.month() == selectedDate.month()) {
int weekDay = date.dayOfWeek();
QTextTableCell cell = table->cellAt(table->rows()-1, weekDay-1);
QTextCursor cellCursor = cell.firstCursorPosition();
if (date == QDate::currentDate())
cellCursor.insertText(QString("%1").arg(date.day()), highlightedFormat);
else
cellCursor.insertText(QString("%1").arg(date.day()), format);
date = date.addDays(1);
if (weekDay == 7 && date.month() == selectedDate.month())
table->insertRows(table->rows(), 1);
}
cursor.endEditBlock();
//! [14]
setWindowTitle(tr("Calendar for %1 %2"
).arg(QDate::longMonthName(selectedDate.month())
).arg(selectedDate.year()));
}
示例5: hacerResumen
void InformeCierreCaja::hacerResumen( int id_caja, bool ultimo, int id_cierre )
{
if( id_caja == -1 ) {
qWarning( "Numero de caja incorrecto" );
//abort();
return;
} else if( ultimo == false && id_cierre == -1 ) {
qWarning( "El cierre pedido es incorrecto" );
//abort();
return;
}
// Busco los datos
MMovimientosCaja *m = new MMovimientosCaja( this );
if( ultimo ) {
id_cierre = m->buscarUltimoCierre( id_caja );
if( id_cierre == -1 ) {
return;
}
}
QSqlQuery resultados = m->buscarMovimientos( id_caja, id_cierre );
///////////////////////////////////////////////////////////////////////////////////////////////////
// Inicio el renderizado
QTextCursor cursor( documento );
int cantidadCol = 6;
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) { cantidadCol++; }
/////////////////////////////////////
/// Hago la cabecera de la tabla
QTextTable *tabla = cursor.insertTable( 1, cantidadCol );
QTextTableFormat formatoTabla = tabla->format();
formatoTabla.setHeaderRowCount( 1 );
formatoTabla.setWidth( QTextLength( QTextLength::PercentageLength, 100 ) );
tabla->setFormat( formatoTabla );
tabla->cellAt( 0,0 ).firstCursorPosition().insertHtml( " # Op " );
tabla->cellAt( 0,1 ).firstCursorPosition().insertHtml( " Fecha/Hora " );
tabla->cellAt( 0,2 ).firstCursorPosition().insertHtml( " Razon " );
tabla->cellAt( 0,3 ).firstCursorPosition().insertHtml( " Ingreso " );
tabla->cellAt( 0,4 ).firstCursorPosition().insertHtml( " Egreso " );
tabla->cellAt( 0,5 ).firstCursorPosition().insertHtml( " Saldo " );
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) {
tabla->cellAt( 0, 6 ).firstCursorPosition().insertHtml( " Responsable " );
}
// Averiguo el saldo hasta el momento del cierre anterior
double saldo_anterior = m->saldoEnMovimientoAnteriorA( id_caja, id_cierre );
while( resultados.next() ) {
int pos = tabla->rows();
tabla->insertRows( pos, 1 );
tabla->cellAt( pos, 0 ).firstCursorPosition().insertHtml( QString( " # %1 " ).arg( resultados.record().value("id_movimiento" ).toInt() ) );
tabla->cellAt( pos, 1 ).firstCursorPosition().insertHtml( resultados.record().value("fecha_hora" ).toDateTime().toString( Qt::SystemLocaleDate ) );
tabla->cellAt( pos, 2 ).firstCursorPosition().insertHtml( resultados.record().value("razon" ).toString() );
if( resultados.record().value( "cierre" ).toBool() == false ) {
// Ingreso
double haber = resultados.record().value( "ingreso" ).toDouble();
saldo_anterior += haber;
tabla->cellAt( pos, 3 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( haber ) );
// Egreso
double debe = resultados.record().value( "egreso" ).toDouble();
saldo_anterior -= debe;
tabla->cellAt( pos, 4 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( debe ) );
// Subtotal hasta el momento
tabla->cellAt( pos, 5 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( saldo_anterior ) );
} else {
saldo_anterior += resultados.record().value( "ingreso" ).toDouble();
tabla->cellAt( pos, 5 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( saldo_anterior ) );
}
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) {
tabla->cellAt( pos, 6 ).firstCursorPosition().insertHtml( resultados.record().value( "responsable" ).toString() );
}
}
// Saldos finales
cursor.movePosition( QTextCursor::End );
cursor.insertBlock();
cursor.insertHtml( QString( "<b>Saldo Final:</b> $ %L1" ).arg( saldo_anterior ) );
cursor.insertBlock();
if( preferencias::getInstancia()->value( "Preferencias/Caja/firma", true ).toBool() ) {
cursor.insertBlock();
cursor.insertText( "Controlado por: ________________________" );
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText( "Firma: ____________" );
}
// Termino el resumen
cursor.movePosition( QTextCursor::Start );
cursor.insertBlock();
if( preferencias::getInstancia()->value( "Preferencias/Caja/logo" ).toBool() ) {
//cursor.insertImage( ERegistroPlugins::pluginInfo()->imagenPrograma() );
cursor.insertImage( ":/imagenes/gestotux32.png" );
}
cursor.insertHtml( "<h1>Cierre de Caja</h1>" );
cursor.insertBlock();
cursor.insertHtml( QString( "<b>Fecha de Cierre:</b> %1 <br />" ).arg( QDateTime::currentDateTime().toString( Qt::SystemLocaleLongDate ) ) );
cursor.insertHtml( QString( "<b>Caja:</b> %1<br />").arg( MCajas::nombreCaja( id_caja ) ) );
return;
}