Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QString remove last characters

Tags:

qt

qstring

How to remove /Job from /home/admin/job0/Job

QString name = "/home/admin/job0/Job"

I want to remove last string after"/"

like image 583
Sijith Avatar asked Nov 09 '17 12:11

Sijith


People also ask

How do you convert QString to double?

How do you convert QString to double in Qt? lineEdit->setText("123456789"); QVariant val = lineEdit->text(). toDouble();

What is QString in Qt?

The QString class provides an abstraction of Unicode text and the classic C '\0'-terminated char array. More... All the functions in this class are reentrant when Qt is built with thread support.

How to initialise a QString?

One way to initialize a QString is simply to pass a const char * to its constructor. For example, the following code creates a QString of size 5 containing the data "Hello": QString str = "Hello"; QString converts the const char * data into Unicode using the fromAscii() function.


1 Answers

You have QString::chop() for the case when you already know how many characters to remove.
It is same as QString::remove(), just works from the back of string.

like image 98
mekkanizer Avatar answered Oct 15 '22 04:10

mekkanizer