PDA

View Full Version : load list



maarvi
23rd May 2011, 20:08
hi,

I'm working on Qt Creator and I am completely new to it. I want to have a list box which is loaded with the data when I run the program and I choose a value from the list box and press button and do some operation on that selected value.

Also, where to write a code to load the list automatically from the file ?

Santosh Reddy
23rd May 2011, 20:25
I want to have a list box which is loaded with the data when I run the program
If your list box data is static, (i,.e doest not change over the life of your program) the best place is the ctor of the list. If the list content can change, then it bettter to have some helper functions to load (init) the which you can use over time as required


Also, where to write a code to load the list automatically from the file ?
have it in aload / init method, and make it slot and connect to a QTimer, as you already did, or you can call it inside a timerEvent(), or evetn stringforward, have a button for refresh list box....many ways ...

maarvi
24th May 2011, 06:48
sir i have checked but ther is no init () method. usually programs has inti method but here i didnt fine any i have no idea where the program started executing this the constructor when i write the code in this it give an error so i dont know where to write the code. :(


analysis::analysis(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::analysis)
{
ui->setupUi(this);
}

Lykurg
24th May 2011, 08:01
Oh, Goodness! You get an error. You should have mentioned it in your first post. Simply use the "solution" to get rid of it.

This was sarcasm, if anyone haven't get it. So what's about telling us what the error is and what code actually cause it? And of course you won't find an init function because you have to write it yourself.