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


C++ Q3CString::rightJustify方法代码示例

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


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

示例1: QCOMPARE

void tst_Q3CString::rightJustify()
{
    Q3CString a;
    a="ABC";
    QCOMPARE(a.rightJustify(5,'-'),(Q3CString)"--ABC");
    QCOMPARE(a.rightJustify(4,'-'),(Q3CString)"-ABC");
    QCOMPARE(a.rightJustify(4),(Q3CString)" ABC");
    QCOMPARE(a.rightJustify(3),(Q3CString)"ABC");
    QCOMPARE(a.rightJustify(2),(Q3CString)"ABC");
    QCOMPARE(a.rightJustify(1),(Q3CString)"ABC");
    QCOMPARE(a.rightJustify(0),(Q3CString)"ABC");

    Q3CString n;
    QVERIFY(!n.rightJustify(3).isNull());  // I expected TRUE
    QCOMPARE(a.rightJustify(4,'-',TRUE),(Q3CString)"-ABC");
    QCOMPARE(a.rightJustify(4,' ',TRUE),(Q3CString)" ABC");
    QCOMPARE(a.rightJustify(3,' ',TRUE),(Q3CString)"ABC");
    QCOMPARE(a.rightJustify(2,' ',TRUE),(Q3CString)"AB");
    QCOMPARE(a.rightJustify(1,' ',TRUE),(Q3CString)"A");
    QCOMPARE(a.rightJustify(0,' ',TRUE),(Q3CString)"");
    QCOMPARE(a,(Q3CString)"ABC");
}
开发者ID:mpvader,项目名称:qt,代码行数:22,代码来源:tst_q3cstring.cpp

示例2: big

b.isNull();                // false because b.data() == ""
b.isEmpty();        // true  because b.length() == 0
//! [1]


//! [2]
Q3CString s = "truncate this string";
s.truncate(5);                      // s == "trunc"
//! [2]


//! [3]
Q3CString s;
s.sprintf("%d - %s", 1, "first");                // result < 256 chars

Q3CString big(25000);                        // very long string
big.sprintf("%d - %s", 2, longString);        // result < 25000 chars
//! [3]


//! [4]
Q3CString s("apple");
Q3CString t = s.leftJustify(8, '.');  // t == "apple..."
//! [4]


//! [5]
Q3CString s("pie");
Q3CString t = s.rightJustify(8, '.');  // t == ".....pie"
//! [5]
开发者ID:bogdan-voevoda,项目名称:qt4,代码行数:30,代码来源:src_qt3support_tools_q3cstring.cpp


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