Hello,
I've got the official book: http://qt.nokia.com/developer/books/...-4-2nd-edition, but I've come to part where I'm not sure which way to go.
I've got an array of 100 integers that are 3 integers long. I've setup my inputmasks on my lineEdits to be able to control this, so data sanitation is already handled. I'm trying to figure out the best way to both display this data, as well as edit it.
- Is it possible to create pointers of lineEdits, put them in a QList container, and display them as well as access them through for() loops?
- Is it possible to create an array within another class, and simply have 100 line edits point to said array. lineEdit00 points to numbers[0]?
- Am I missing something?
Any help would be great. Thanks for such a nice forum to ask questions.
-bobby
for(int i = 0; i < 100; i++)
{
// Setup the proper label
if( i < 10)
{
labelPtr
= new QLabel(tr
("0%1").
arg(i
));
}else{
labelPtr
= new QLabel(tr
("%1").
arg(i
));
}
// Now the Address Cell
lePtr->setInputMask("999");
// if it's cell 00 make uneditable
if(i < 1)
{
lePtr->setText("001");
lePtr->setReadOnly(true);
}
memAddr.append(lePtr);
}
// Fill in the layout and display it
for( int i = 0; i < 100; i++)
{
layout->addWidget(memAddr.at(i));
}
window->setLayout(layout);
window->show();
for(int i = 0; i < 100; i++)
{
// Setup the proper label
if( i < 10)
{
labelPtr = new QLabel(tr("0%1").arg(i));
}else{
labelPtr = new QLabel(tr("%1").arg(i));
}
// Now the Address Cell
lePtr = new QLineEdit();
lePtr->setInputMask("999");
// if it's cell 00 make uneditable
if(i < 1)
{
lePtr->setText("001");
lePtr->setReadOnly(true);
}
memAddr.append(lePtr);
}
// Fill in the layout and display it
for( int i = 0; i < 100; i++)
{
layout->addWidget(memAddr.at(i));
}
window->setLayout(layout);
window->show();
To copy to clipboard, switch view to plain text mode
EDIT:
Ok so I put my line edits into a QList, and I'm going to call them. my idea is that I have to use a forloop similar to the one I did, but with the addition to the labels as well.
I really need to know how to take something like this that I pulled off, and put it into my application. Do I stick everything into the mainWindow.cpp (implementation) or do I make a new class, I really don't know.
Another thought is to promote a groupbox into a "myGroupBox" and have the code run in there, but I'm really not clear how to do that, even with the help of Google.
-Bobby
Bookmarks