Convert std::string to QLineEdit

  • Hi all,

    So I have a situation...

    The following code allows me to set the text in a QLineEdit called cores using a map called parameterMap:


    I have a list called allParameters, the entries of which are identical to the keys of parameterMap and the QLineEdit's in advancedsettings. I would like to iterate over allParameters to change the text in every QLineEdit in advancedsettings like so:

    "for(list<string>::iterator it = allParameters.begin(); it != allParameters.end(); ++it){

    However, the above code produces:
    error: 'struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'setText'


    "string myString = "cores";

    results in:
    'class Ui::AdvancedSettings' has no member named 'myString'

    How can I achieve what I want to? I must need to convert a std::string to some QT data type but none of my attempts have worked.

    Many thanks,

  • Lifetime Qt Champion

    Hi and welcome to devnet,


    Is the correct form.

    Do you have as much QLineEdit in your UI to enter all the strings from your parameterMap ?

  • Hi!

    Many thanks for your help.

    To answer your question I have more strings in parameterMap than QLineEdit's in the UI (advancedsettings).

    I'd like to iterate through all the QLineEdit's in advancedsettings rather than manually having to do something like:





    Is there a way I can achieve this?

    Man thanks,

  • Lifetime Qt Champion

    You can create the QLineEdits dynamically

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.