Solved How to convert from 'QStringList' to 'const QStringList *'
-
how to convert from 'QStringList' to 'const QStringList *'.
-
QStringList a; const QStringList *b = &a;
Be careful with it, though.
-
@sierdzio said in How to convert from 'QStringList' to 'const QStringList *':
Be careful with it, though.
As long as it's
const
, no harm can be done. Amen. -
@sierdzio I am getting asserts error before launch of my UI.
-
As long as it's
const
, no harm can be done. Amen.(const_cast<QStringList *>(b))->clear();
;-)
-
@Shankar-B my magic 8 ball says:
...Show some code
-
@Shankar-B said in How to convert from 'QStringList' to 'const QStringList *':
@sierdzio I am getting asserts error before launch of my UI.
Random ones? Ones @sierdzio should guess? Ones where if you run from debugger you do not get stack trace back to your code?
-
@J-Hilk const QStringList *pVariableTextsForDetails= &alarmDetails.m_variableTextsForDetails;
where m_variableTextsForDetails is a member of structure alarmDetails which of type QstringList.
-
@Shankar-B wow you're really minimalistic.
heres a working example:
struct myStruct { QStringList m_StringList; }; int main (int argc, char *argv[]) { QApplication app(argc, argv); myStruct s; s.m_StringList << "A"; const QStringList *sl = &s.m_StringList; qDebug() << sl->first(); return app.exec(); }
the problem is on your side
-
@J-Hilk said in How to convert from 'QStringList' to 'const QStringList *':
struct myStruct
{
QStringList m_StringList;
};int main (int argc, char *argv[])
{
QApplication app(argc, argv);myStruct s; s.m_StringList << "A"; const QStringList *sl = &s.m_StringList; qDebug() << sl->first();
Issue solved. Thanks for help.