Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to remove Singlequotes?
Forum Updated to NodeBB v4.3 + New Features

How to remove Singlequotes?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 221 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    n-2204
    wrote on last edited by
    #1

    Hi,

    I have Qstringlist and i need to remove single quotes of item at 0 index, and then store in a Qstring. but i didn't find any method like remove.
    Plz tell how to do this ?

       QStringList DataItem;
       QString qsType="";
       QString Singlequote;
       Singlequote="\'";
       qsType = DataItem.at(0).remove(Singlequote);//there is no remove function in Qstringlist.
    

    Thankyou

    J.HilkJ 1 Reply Last reply
    0
    • N n-2204

      Hi,

      I have Qstringlist and i need to remove single quotes of item at 0 index, and then store in a Qstring. but i didn't find any method like remove.
      Plz tell how to do this ?

         QStringList DataItem;
         QString qsType="";
         QString Singlequote;
         Singlequote="\'";
         qsType = DataItem.at(0).remove(Singlequote);//there is no remove function in Qstringlist.
      

      Thankyou

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @n-2204

      there is no remove function in Qstringlist.

      thats wrong, QStringList and QString(what you're actually trying to modify here) have remove functions

      The problem you're having is, that you try to modify a const QString ref

      QString::remove modifies the QString object and returns a reference of the string.

      quick and dirty fix:

      qsType = QString(DataItem.at(0)).remove(Singlequote);
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      2
      • N Offline
        N Offline
        n-2204
        wrote on last edited by n-2204
        #3
        This post is deleted!
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved