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


C++ QTextEdit::paragraphLength方法代码示例

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


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

示例1:

void
QUimTextUtil::QTextEditPositionBackward( int *cursor_para, int *cursor_index )
{
    QTextEdit *edit = (QTextEdit *)mWidget;
    int preedit_len, preedit_cursor_pos;
    int para, index;
    int current_para, current_index;

    current_para = *cursor_para;
    current_index = *cursor_index;

    if ( ! mPreeditSaved ) {
        preedit_len = mIc->getPreeditString().length();
        preedit_cursor_pos = mIc->getPreeditCursorPosition();
    } else {
        preedit_len = 0;
        preedit_cursor_pos = 0;
    }
    edit->getCursorPosition( &para, &index );

    if ( current_para == para && current_index > ( index - preedit_cursor_pos ) && ( current_index <= ( index - preedit_cursor_pos + preedit_len ) ) )
        current_index = index - preedit_cursor_pos;

    if ( current_index > 0 )
        current_index--;
    else {
        if ( current_para > 0 ) {
            current_para--;
            current_index = edit->paragraphLength( current_para );
        }
    }

    *cursor_para = current_para;
    *cursor_index = current_index;
}
开发者ID:DirtYiCE,项目名称:uim,代码行数:35,代码来源:qtextutil.cpp

示例2: if

int
QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
                                            int former_req_len,
                                            int latter_req_len )
{
    QTextEdit *edit = (QTextEdit *)mWidget;
    int i;
    int start_para, start_index, end_para, end_index, para, index;
    int n_para;

    savePreedit();

    edit->getCursorPosition( &para, &index );
    n_para = edit->paragraphs();

    switch ( origin ) {
    case UTextOrigin_Cursor:
        start_index = index;
        start_para = para;
        end_index = start_index;
        end_para = para;

        if ( former_req_len >= 0 ) {
            for ( i = 0; i < former_req_len; i++ )
                QTextEditPositionBackward( &start_para, &start_index );
        } else {
            if ( former_req_len == UTextExtent_Line ) {
                start_index = 0;
            } else if ( former_req_len == UTextExtent_Full ) {
                start_para = 0;
                start_index = 0;
            } else {
                restorePreedit();
                return -1;
            }
        }
        if ( latter_req_len >= 0 ) {
            for ( i = 0; i < latter_req_len; i++ )
                QTextEditPositionForward( &end_para, &end_index );
        } else {
            if ( latter_req_len == UTextExtent_Line ) {
                end_index = edit->paragraphLength( end_para );
            } else if ( latter_req_len == UTextExtent_Full ) {
                end_para = n_para - 1;
                end_index = edit->paragraphLength( end_para );
            } else {
                restorePreedit();
                return -1;
            }
        }
        break;

    case UTextOrigin_Beginning:
        start_para = 0;
        start_index = 0;
        end_para = start_para;
        end_index = start_index;

        if ( latter_req_len >= 0 ) {
            for ( i = 0; i < latter_req_len; i++ )
                QTextEditPositionForward( &end_para, &end_index );
        } else {
            if ( latter_req_len == UTextExtent_Line ) {
                end_index = edit->paragraphLength( end_para );
            } else if ( latter_req_len == UTextExtent_Full ) {
                end_para = n_para - 1;
                end_index = edit->paragraphLength( end_para );
            } else {
                restorePreedit();
                return -1;
            }
        }
        break;

    case UTextOrigin_End:
        end_para = n_para - 1;
        end_index = edit->paragraphLength( end_para );
        start_para = end_para;
        start_index = end_index;

        if ( former_req_len >= 0 ) {
            for ( i = 0; i < former_req_len; i++ )
                QTextEditPositionBackward( &start_para, &start_index );
        } else {
            if ( former_req_len == UTextExtent_Line )
                start_index = 0;
            else if ( former_req_len == UTextExtent_Full ) {
                start_para = 0;
                start_index = 0;
            } else {
                restorePreedit();
                return -1;
            }
        }
        break;

    case UTextOrigin_Unspecified:
    default:
        restorePreedit();
        return -1;
//.........这里部分代码省略.........
开发者ID:DirtYiCE,项目名称:uim,代码行数:101,代码来源:qtextutil.cpp


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