QString Snippets: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
note: This page will contain code snippets of all QString functions
note: This page will contain code snippets of all QString functions


'''QString::endsWith()'''<br />Returns true if the string ends with s; otherwise returns false.<br /><code><br />#include &lt;QTextStream&amp;gt;<br />#include &lt;QString&amp;gt;
'''QString::endsWith()'''
Returns true if the string ends with s; otherwise returns false.
<code>
#include <QTextStream>
#include <QString>


int main()<br />{<br /> QTextStream out(stdout);<br /> QString *string = new QString(&quot;example-0.0.1.tar.gz&amp;quot;);
int main()
{
QTextStream out(stdout);
QString *string = new QString("example-0.0.1.tar.gz");


if (string-&gt;endsWith(&quot;.tar.gz&amp;quot;) == true) {<br /> out &lt;&lt; &quot;True\n&amp;quot;;<br /> } else {<br /> out &lt;&lt; &quot;False\n&amp;quot;;<br /> }<br />}
if (string->endsWith(".tar.gz") == true) {
out << "True\n";
} else {
out << "False\n";
}
}

Revision as of 12:43, 25 February 2015

note: This page will contain code snippets of all QString functions

QString::endsWith() Returns true if the string ends with s; otherwise returns false.

  1. include <QTextStream>
  2. include <QString>

int main() {

QTextStream out(stdout);
QString *string = new QString("example-0.0.1.tar.gz");

if (string->endsWith(".tar.gz") == true) {

out << "True\n";
} else {
out << "False\n";
}

}