Modifying a QString that contains a “”How to change string into QString?Qt QString cloning Segmentation FaultQString to char* conversionConvert an int to a QString with zero padding (leading zeroes)How to convert int to QString?How to convert QString to std::string?Convert std::string to QStringWhy is this QString to const char* conversion producing a Debian identifier on Windows?Return a QString from a function - thread safe?Extract character from QString and compare
Why are angular mometum and angular velocity not necessarily parallel, but linear momentum and linear velocity are always parallel?
How can I tell if there was a power cut while I was out?
Company messed up with patent and now a lawyer is coming after me
Why are so many countries still in the Commonwealth?
What is "ass door"?
Current relevance: "She has broken her leg" vs. "She broke her leg yesterday"
Should I leave my PhD after 3 years with a Masters?
How may I shorten this shell script?
How can I create a shape in Illustrator which follows a path in descending order size?
Why is chess failing to attract big name sponsors?
Memory capability and powers of 2
Are gangsters hired to attack people at a train station classified as a terrorist attack?
How can I make sure my players' decisions have consequences?
Talk to manager when quitting my job
What are the exact meanings of roll, pitch and yaw?
What is a Union Word™?
Spacing setting of math mode
What is the meaning of "you has the wind of me"?
Spoken encryption
Is it legal for private citizens to "impound" e-scooters?
Book about young girl who ends up in space after apocolypse
How can I stop myself from micromanaging other PCs' actions?
Can two figures have the same area, perimeter, and same number of segments have different shape?
Invert Some Switches on a Switchboard
Modifying a QString that contains a “”
How to change string into QString?Qt QString cloning Segmentation FaultQString to char* conversionConvert an int to a QString with zero padding (leading zeroes)How to convert int to QString?How to convert QString to std::string?Convert std::string to QStringWhy is this QString to const char* conversion producing a Debian identifier on Windows?Return a QString from a function - thread safe?Extract character from QString and compare
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to modify a QString. The Qstring that I'm trying to modify is
"02"
However when I try to modify it, the string either gets entirely deleted or shows no change.
I've tried
String.split(""");
String.remove(""");
String.remove(QChar(''');
for some reason Qt requires that I add an extra " or ' in order to compile and not produce errors
What I currently have is this
string = pointer->data.info.get_type();
which according to the debugger returns "02"
string = string.remove(QChar('''));
the remove functionality does nothing afterwards.
I'm expecting to remove the from the string, but either it gets entirely deleted or nothing happens. What could be the problem and how do I modify the Qstring to just be the numerical values?
c++ qt qstring
add a comment |
I'm trying to modify a QString. The Qstring that I'm trying to modify is
"02"
However when I try to modify it, the string either gets entirely deleted or shows no change.
I've tried
String.split(""");
String.remove(""");
String.remove(QChar(''');
for some reason Qt requires that I add an extra " or ' in order to compile and not produce errors
What I currently have is this
string = pointer->data.info.get_type();
which according to the debugger returns "02"
string = string.remove(QChar('''));
the remove functionality does nothing afterwards.
I'm expecting to remove the from the string, but either it gets entirely deleted or nothing happens. What could be the problem and how do I modify the Qstring to just be the numerical values?
c++ qt qstring
4
You should read up about escape sequences in c++ strings. You need"\"
not"""
to search for a slash, the second one searches for a quote
– Alan Birtles
Mar 26 at 15:58
You wantString.split("\");
, notString.split(""");
.
– Jesper Juhl
Mar 26 at 15:58
Put another way: What would you think is the reason that there are three instances of"
inString.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a"
to shut it up without considering why""
didn't work.
– Max Langhof
Mar 26 at 16:14
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20
add a comment |
I'm trying to modify a QString. The Qstring that I'm trying to modify is
"02"
However when I try to modify it, the string either gets entirely deleted or shows no change.
I've tried
String.split(""");
String.remove(""");
String.remove(QChar(''');
for some reason Qt requires that I add an extra " or ' in order to compile and not produce errors
What I currently have is this
string = pointer->data.info.get_type();
which according to the debugger returns "02"
string = string.remove(QChar('''));
the remove functionality does nothing afterwards.
I'm expecting to remove the from the string, but either it gets entirely deleted or nothing happens. What could be the problem and how do I modify the Qstring to just be the numerical values?
c++ qt qstring
I'm trying to modify a QString. The Qstring that I'm trying to modify is
"02"
However when I try to modify it, the string either gets entirely deleted or shows no change.
I've tried
String.split(""");
String.remove(""");
String.remove(QChar(''');
for some reason Qt requires that I add an extra " or ' in order to compile and not produce errors
What I currently have is this
string = pointer->data.info.get_type();
which according to the debugger returns "02"
string = string.remove(QChar('''));
the remove functionality does nothing afterwards.
I'm expecting to remove the from the string, but either it gets entirely deleted or nothing happens. What could be the problem and how do I modify the Qstring to just be the numerical values?
c++ qt qstring
c++ qt qstring
asked Mar 26 at 15:55
BChiuBChiu
297 bronze badges
297 bronze badges
4
You should read up about escape sequences in c++ strings. You need"\"
not"""
to search for a slash, the second one searches for a quote
– Alan Birtles
Mar 26 at 15:58
You wantString.split("\");
, notString.split(""");
.
– Jesper Juhl
Mar 26 at 15:58
Put another way: What would you think is the reason that there are three instances of"
inString.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a"
to shut it up without considering why""
didn't work.
– Max Langhof
Mar 26 at 16:14
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20
add a comment |
4
You should read up about escape sequences in c++ strings. You need"\"
not"""
to search for a slash, the second one searches for a quote
– Alan Birtles
Mar 26 at 15:58
You wantString.split("\");
, notString.split(""");
.
– Jesper Juhl
Mar 26 at 15:58
Put another way: What would you think is the reason that there are three instances of"
inString.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a"
to shut it up without considering why""
didn't work.
– Max Langhof
Mar 26 at 16:14
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20
4
4
You should read up about escape sequences in c++ strings. You need
"\"
not """
to search for a slash, the second one searches for a quote– Alan Birtles
Mar 26 at 15:58
You should read up about escape sequences in c++ strings. You need
"\"
not """
to search for a slash, the second one searches for a quote– Alan Birtles
Mar 26 at 15:58
You want
String.split("\");
, not String.split(""");
.– Jesper Juhl
Mar 26 at 15:58
You want
String.split("\");
, not String.split(""");
.– Jesper Juhl
Mar 26 at 15:58
Put another way: What would you think is the reason that there are three instances of
"
in String.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a "
to shut it up without considering why ""
didn't work.– Max Langhof
Mar 26 at 16:14
Put another way: What would you think is the reason that there are three instances of
"
in String.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a "
to shut it up without considering why ""
didn't work.– Max Langhof
Mar 26 at 16:14
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20
add a comment |
2 Answers
2
active
oldest
votes
You're currently asking Qt to remove "
from your string, not . To remove
, you'll have to escape it, just like you escaped
"
, i.e. remove("\")
.
add a comment |
First of all your string "02"
do not contain any slash, quotes or apostrophes.
Read about C++ string literals. This is escape sequence.
Note nnn
represents arbitrary octal value!
So your literal contains only one character of value decimal value 2
! This is ASCII spatial code meaning: STX
(start of text)
As a result this code:
String.split(""");
String.remove(""");
String.remove(QChar(''');
won't split or anything since this string do not contain quote characters or apostrophe. It also do not tries split or remove slash character, since again this is an escape sequence, but different kind.
Now remember that debugger shows you this unprintable characters in escaped form to show you actual content. In live application user will see nothing or some strange glyph.
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361362%2fmodifying-a-qstring-that-contains-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're currently asking Qt to remove "
from your string, not . To remove
, you'll have to escape it, just like you escaped
"
, i.e. remove("\")
.
add a comment |
You're currently asking Qt to remove "
from your string, not . To remove
, you'll have to escape it, just like you escaped
"
, i.e. remove("\")
.
add a comment |
You're currently asking Qt to remove "
from your string, not . To remove
, you'll have to escape it, just like you escaped
"
, i.e. remove("\")
.
You're currently asking Qt to remove "
from your string, not . To remove
, you'll have to escape it, just like you escaped
"
, i.e. remove("\")
.
answered Mar 26 at 15:58
gsprgspr
7,6842 gold badges30 silver badges63 bronze badges
7,6842 gold badges30 silver badges63 bronze badges
add a comment |
add a comment |
First of all your string "02"
do not contain any slash, quotes or apostrophes.
Read about C++ string literals. This is escape sequence.
Note nnn
represents arbitrary octal value!
So your literal contains only one character of value decimal value 2
! This is ASCII spatial code meaning: STX
(start of text)
As a result this code:
String.split(""");
String.remove(""");
String.remove(QChar(''');
won't split or anything since this string do not contain quote characters or apostrophe. It also do not tries split or remove slash character, since again this is an escape sequence, but different kind.
Now remember that debugger shows you this unprintable characters in escaped form to show you actual content. In live application user will see nothing or some strange glyph.
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
add a comment |
First of all your string "02"
do not contain any slash, quotes or apostrophes.
Read about C++ string literals. This is escape sequence.
Note nnn
represents arbitrary octal value!
So your literal contains only one character of value decimal value 2
! This is ASCII spatial code meaning: STX
(start of text)
As a result this code:
String.split(""");
String.remove(""");
String.remove(QChar(''');
won't split or anything since this string do not contain quote characters or apostrophe. It also do not tries split or remove slash character, since again this is an escape sequence, but different kind.
Now remember that debugger shows you this unprintable characters in escaped form to show you actual content. In live application user will see nothing or some strange glyph.
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
add a comment |
First of all your string "02"
do not contain any slash, quotes or apostrophes.
Read about C++ string literals. This is escape sequence.
Note nnn
represents arbitrary octal value!
So your literal contains only one character of value decimal value 2
! This is ASCII spatial code meaning: STX
(start of text)
As a result this code:
String.split(""");
String.remove(""");
String.remove(QChar(''');
won't split or anything since this string do not contain quote characters or apostrophe. It also do not tries split or remove slash character, since again this is an escape sequence, but different kind.
Now remember that debugger shows you this unprintable characters in escaped form to show you actual content. In live application user will see nothing or some strange glyph.
First of all your string "02"
do not contain any slash, quotes or apostrophes.
Read about C++ string literals. This is escape sequence.
Note nnn
represents arbitrary octal value!
So your literal contains only one character of value decimal value 2
! This is ASCII spatial code meaning: STX
(start of text)
As a result this code:
String.split(""");
String.remove(""");
String.remove(QChar(''');
won't split or anything since this string do not contain quote characters or apostrophe. It also do not tries split or remove slash character, since again this is an escape sequence, but different kind.
Now remember that debugger shows you this unprintable characters in escaped form to show you actual content. In live application user will see nothing or some strange glyph.
edited Mar 26 at 16:15
answered Mar 26 at 16:10
Marek RMarek R
14.9k3 gold badges30 silver badges81 bronze badges
14.9k3 gold badges30 silver badges81 bronze badges
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
add a comment |
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
1
1
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
It really depends, maybe "02" is truly what the string contains (i.e. the source code actually has "\002", although I wouldn't bet on that). You got my +1 though because this aspect is indeed important to be aware of here.
– Max Langhof
Mar 26 at 16:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361362%2fmodifying-a-qstring-that-contains-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
You should read up about escape sequences in c++ strings. You need
"\"
not"""
to search for a slash, the second one searches for a quote– Alan Birtles
Mar 26 at 15:58
You want
String.split("\");
, notString.split(""");
.– Jesper Juhl
Mar 26 at 15:58
Put another way: What would you think is the reason that there are three instances of
"
inString.split(""");
? It appears that the compiler complained about an unclosed string/character literal and you just added a"
to shut it up without considering why""
didn't work.– Max Langhof
Mar 26 at 16:14
question is about C++ basic, but it is well written question, describing what is expected and what is seen, so I will vote it up.
– Marek R
Mar 26 at 16:20