Unsolved how to declare the static QString
-
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! -
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{
. -
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 -
@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
-
@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" };
-
@J.Hilk Dude! we are discussing philosophy here! go away you and your actually useful solutions! 😆
-
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.