Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5941397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:06:14+00:00 2026-05-22T16:06:14+00:00

I use Qt extensively in a software system I’m working on for graphical and

  • 0

I use Qt extensively in a software system I’m working on for graphical and GUI components. However, for most internal algorithms and processing of data Qt plays a smaller role.

I’ll often run into the need to convert from std::string to QString or visa versa. My inclination is to use std::string as much as possible and use QString only when I need to pass strings to Qt classes like those that work with the file system.

As I was programming this morning, it hit me that it may be bad design to have both std::string and QString sprinkled throughout my code. Should I completely switch to QString? Has anyone else run into this design choice?

Qt provides a lot of the same functionality of STL, but I’m still hesitant switching completely since Qt is less standardized and stable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:06:15+00:00Added an answer on May 22, 2026 at 4:06 pm

    Yes, I’ve had this situation before. The program I worked on used Qt throughout, but I had to hook it up to a library that expected std::string. The benefit of QString is that it explicitly uses Unicode, while the C++ standard library makes no guarantees about encoding.

    The solution was to convert at the boundary of this library with

    QString toQString(std::string const &s)
    {
        return QString::fromUtf8(s.c_str());
    }
    
    std::string fromQString(QString const &s)
    {
        return std::string(s.toUtf8().data());
    }
    

    since the library produced std::string‘s containing UTF-8.

    What you seem to want is the exact opposite: use std::string throughout and convert at the Qt boundary. That seems perfectly ok; it takes a bit more work than always using QString, but you’ll have to put in effort when you need a non-QString-accepting library anyway, and your non-GUI components don’t depend on Qt (hurrah!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using DataVisualization.Charting.Chart extensively, and for the most part it is working. However,
I use version control extensively. When I'm working by myself, I still use it,
we identify client software using Version class and use these values extensively, we also
We extensively use a third party app that we'll call thirdparty.com. thirdparty.com and mysite.com
I use XmlSerializer extensively and rather than allowing .NET to generate the necessary serialization
I'm a huge fan of robocopy and use it extensively to copy between various
Firebug is certainly a wonderful tool for javascript debugging; I use console.log() extensively. I
I use std::tr1::shared_ptr extensively throughout my application. This includes passing objects in as function
I tend to use the bisect command in git extensively. Now I want to
I've been using user controls extensively but never use a HttpHandler and was wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.