how do you add text to a QCombobox in QT

How do you add text to a QCombobox?  I'm having trouble with the syntax of what I am trying to enter.

I want to add "line1", "line2", and "line3" to my QCombobox.  What are the lines of code that will make this happen?  I don't think this is a difficult question but I can't get the syntax right.

Thanks
dwcroninAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwad99Commented:
0
dwcroninAuthor Commented:
yes -  I can't get it to work.  I tried:

myclassname->insertItem("a",-1);

But it doesn't do anything?
0
mrwad99Commented:
>> insertItem

You need to pass a QString (http://www.handhelds.org/~zecke/apidocs/qt/qstring.html) to that function.

Try

QString qString("a");
myclassname->insertItem(qString,-1);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

dwcroninAuthor Commented:
thank you
0
rajeev_devinCommented:
Try this
QComboBox* combo;
combo->addItem ( "line1" );
combo->addItem ( "line2" );
combo->addItem ( "line3" );

If you are using insertItem then do this

combo->insertItem ( 0, "line1" );
combo->insertItem ( 1, "line2" );
combo->insertItem ( 2, "line3" );
0
mrwad99Commented:
0
rajeev_devinCommented:
Let me clear your confusion :)

This documentation is of old Qt version Qt3
http://www.handhelds.org/~zecke/apidocs/qt/qcombobox.html#613b4b

This documentation is of new Qt version Qt4
http://doc.trolltech.com/4.1/qcombobox.html#insertItem

There is a big change between these two versions.
0
rajeev_devinCommented:
But as dwcronin said, he is getting compilation error.
I thought he may be using the newer version Qt4.

But its better to Qt4 than Qt3 as Trolltech has stopped providing support for Qt3.
0
mrwad99Commented:
Thanks rajeev_devin :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.