Arrays And an error when trying to declare them
-
[quote author="Andre" date="1316946119"]Instead of using arrays, look into using the standard Qt container classes. They are much easier to use. Containers in Qt include QList, QVector, QHash, QMap and some others. In your case, you might want to look into using QStringList.[/quote]
Heh awesome thanks !! Only reason why I'm saying heh, is because I can get Gentoo intalled, and KDE running, but yet, I can't do something so simple as getting an Array working, =P.. LOL
-
You most probably want to use [[Doc:QStringList]] in order to populate the combobox with "QComboBox::addItems() ":http://doc.qt.nokia.com/4.7/qcombobox.html#addItems
-
[quote author="Volker" date="1317018923"]You most probably want to use [[Doc:QStringList]] in order to populate the combobox with "QComboBox::addItems() ":http://doc.qt.nokia.com/4.7/qcombobox.html#addItems[/quote]
THanks for the post, starting to get irritated here, I did it how I thought it was going to be, I have included my ScoreBoard.h ScoreBoard.cpp Scoreboard.pro and main.cpp files, I cannot seem to figure out what I'm doing wrong.. Here's an error Im getting:
[code]
/home/rottingdead/Desktop/Programming_Folders/ScoreBoard/ScoreBoard.h:12: error: conversion from 'const char [17]' to non-scalar type 'QStringList' requested
[/code][code]
// the included files sources;http://ompldr.org/vYWpycQ/ScoreBoard.cpp
http://ompldr.org/vYWpycg/ScoreBoard.h
http://ompldr.org/vYWpycw/ScoreBoard.pro
http://ompldr.org/vYWpydQ/main.cpp
[/code]Just cannot seem to figure this out, =/. I remember one day, I was working on this Recipes Program, and it worked fine, but can't recall what I did then.
-
You are not declaring the lists properly. Check the usage "here":http://doc.qt.nokia.com/stable/qstringlist.html
One of the ways to declare and populate a QStringList is like this
@
QStringList AFC_North;
AFC_North << "Baltimore Ravens" << "Cincinnati Bengals" << "Cleveland Browns" << "Pittsburgh Steelers";
@Edit: You can always get how much elements there are in the list with the .size() method (just clarifying, read the docs, it's all there).
Edit2: Actually Volker's link has all you need about constructing a string list with good enough examples, more compact then the class reference, you should read that first.
-
[quote author="Eus" date="1317107956"]You are not declaring the lists properly. Check the usage "here":http://doc.qt.nokia.com/stable/qstringlist.html
One of the ways to declare and populate a QStringList is like this
@
QStringList AFC_North;
AFC_North << "Baltimore Ravens" << "Cincinnati Bengals" << "Cleveland Browns" << "Pittsburgh Steelers";
@Edit: You can always get how much elements there are in the list with the .size() method (just clarifying, read the docs, it's all there).
Edit2: Actually Volker's link has all you need about constructing a string list with good enough examples, more compact then the class reference, you should read that first.[/quote]
Oh oh oh, sorry, I didn't even notice that link, =/. Sorry, but that thing you wrote for me didn't work, =/. Already had a squiggly red line under the NFC_North << ""; part, said declaration expected, I wouldn't even know where to being to fix that.
-
You will have to change quite some things.
Begin by moving your QStringList declarations from your .h file to your .cpp file, put them in the constructor, before adding them to the combo boxes.In your scoreboard.cpp, use the .size() method I told you about earlier. And fix your "for" loops! You do not put type for the "i" variable!
@
for (int i = 0; i < AFC_North.size(); i++)
{
AFC_North_ComboBox->addItem(AFC_North.at(i));
}
@Note - I haven't tested your code, that's just the errors I see at a glance, there could be more errors, these were just a few obvious ones.
-
[quote author="Eus" date="1317111412"]You will have to change quite some things.
Begin by moving your QStringList declarations from your .h file to your .cpp file, put them in the constructor, before adding them to the combo boxes.In your scoreboard.cpp, use the .size() method I told you about earlier. And fix your "for" loops! You do not put type for the "i" variable!
@
for (int i = 0; i < AFC_North.size(); i++)
{
AFC_North_ComboBox->addItem(AFC_North.at(i));
}
@Note - I haven't tested your code, that's just the errors I see at a glance, there could be more errors, these were just a few obvious ones.[/quote]
THanks, =). Getting very sleepy to even comprehend anything right now, =P. I'm about to lay down, and have at it later, hehe.
-
Okay, up to you, let us know about the results. And yeah, writing code when you are half asleep always tends to produce bad code - been there, done that :P
-
[quote author="Eus" date="1317112814"]Okay, up to you, let us know about the results. And yeah, writing code when you are half asleep always tends to produce bad code - been there, done that :P[/quote]
LOL, isn't that always the way? I'm not just fighting with Qt, I'm also fighting with Gentoo, trying to get it to detect my envy VIA sound card, even reconfigured Kernel, updated my bzImage in /boot, and still not working, so irritating, hahaha..
-
[quote author="RichardM198030" date="1317111854"]
[quote author="Eus" date="1317111412"]You will have to change quite some things.
Begin by moving your QStringList declarations from your .h file to your .cpp file, put them in the constructor, before adding them to the combo boxes.In your scoreboard.cpp, use the .size() method I told you about earlier. And fix your "for" loops! You do not put type for the "i" variable!
@
for (int i = 0; i < AFC_North.size(); i++)
{
AFC_North_ComboBox->addItem(AFC_North.at(i));
}
@Note - I haven't tested your code, that's just the errors I see at a glance, there could be more errors, these were just a few obvious ones.[/quote]
Awesome, thanks, =). It worked and I see the names in the comboboxes, =). Salute !!
[/quote] -
Read the "API docs":http://doc.qt.nokia.com/4.7/qcombobox.html and discover the "convenience methods":http://doc.qt.nokia.com/4.7/qcombobox.html#addItems.
And subsequently avoid four-liners, where a one-liner is sufficient:
@
AFC_North_ComboBox->addItems(AFC_North);
@ -
[quote author="Volker" date="1317204423"]Read the "API docs":http://doc.qt.nokia.com/4.7/qcombobox.html and discover the "convenience methods":http://doc.qt.nokia.com/4.7/qcombobox.html#addItems.
And subsequently avoid four-liners, where a one-liner is sufficient:
@
AFC_North_ComboBox->addItems(AFC_North);
@
[/quote]Yeah, either way, it's working, =).