本文整理汇总了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");
}
示例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]