View Full Version : Qt won't recognize QString::replace function.
Warumato
19th March 2020, 01:47
Hello
I've got trouble with this line of code:
expr.replace(*start - 1, *end - *start - 1, result_s);
where *start and *end are pointers to integers(table adresses), and result_s is a string.
The error message: no matching member function for call to 'replace'.
This is a precise function I meant to call: https://doc.qt.io/qt-5/qstring.html#replace .
Using Qt Creator 4.11.0 with C++.
d_stranz
19th March 2020, 15:25
and result_s is a string
A std:: string, a char * pointer to a C string, or a QString? If it is not a QString, then there is no match to a QString member function.
Another problem could be that if *start and *end are not "int" types (you said they were addresses), and so the results of the expressions are something larger, like unsigned long long. Again, there is no match. Forcing *start and *end to "int" via a cast could be an error too - forcing an address to an int means that the replace() method isn't actually receiving the true address but a truncated, incorrect value.
Lesiok
19th March 2020, 16:56
A std:: string, a char * pointer to a C string, or a QString? If it is not a QString, then there is no match to a QString member function.
Another problem could be that if *start and *end are not "int" types (you said they were addresses), and so the results of the expressions are something larger, like unsigned long long. Again, there is no match. Forcing *start and *end to "int" via a cast could be an error too - forcing an address to an int means that the replace() method isn't actually receiving the true address but a truncated, incorrect value.
Sorry d_stranz but if start is a "pointer to int" so *start gives int value. Maybe Warumato would show more code, especially start, end and result_s.
d_stranz
19th March 2020, 17:41
Sorry d_stranz but if start is a "pointer to int" so *start gives int value.
The OP's description is unclear. Yes, he said "pointers to ints", but then he also said "table addresses". I understood that to mean the de-referenced pointers were themselves addresses of memory locations, and those would probably be larger than int.
Some more code would definitely help. I am isolated at home, and unfortunately my crystal ball is at the office.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.