how to declare the static QString
-
wrote on 12 Jun 2017, 06:37 last edited by
Hi, I'm using QT5.5 on my computer.
I declare a static QString like below.static QString test_item[9] { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition", };
And it will give me an error when i compile it.
Did i miss anything?
Please help! -
wrote on 12 Jun 2017, 06:46 last edited by
You should have posted the error to help us finding the issue.
In this case, I would say you're missing a
=
sign betweentest_items[9]
and{
. -
wrote on 12 Jun 2017, 07:13 last edited by
This case is also an excellent example of where you want to use QStringLiteral
-
And I would use a
QStringList
instead of a C array -
wrote on 13 Jun 2017, 09:59 last edited by
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
-
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
@VRonin said in how to declare the static QString:
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
That's indeed the best of both worlds
-
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
@VRonin said in how to declare the static QString:
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
And I'll answer the problem :-P
remove the last
,
thats not supposed to be therestatic QString test_item[9] { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition" };
-
@VRonin said in how to declare the static QString:
@JKSH said in how to declare the static QString:
And I would use a
QStringList
instead of a C arrayI raise you
std::array<QString,9>
And I'll answer the problem :-P
remove the last
,
thats not supposed to be therestatic QString test_item[9] { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition" };
-
wrote on 13 Jun 2017, 15:09 last edited by
static QString test_item[9] = { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition", };
works for me as does
static QString test_item[] { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition", };
and
static QString test_item[] = { "Touch", "Panel", "Comport", "USB_SD", "LAN", "CAN", "Audio", "DIDO", "Ignition", };
Might be a compiler thing. I'm using Windows mingw which came with 5.9.
1/9