A school project has had me learn Qt. Which I learned the pronunciation is (cute) from a Youtube tutorial. In this program we have a GUI that is sending to and receiving from a business logic(BL) that sends to and receives from a database(DB). The latest challenge is receiving from the BL and populating fields on the GUI. One of the problems I solved. So I have a custom widget that declares another custom widget.
class custom : public QWidget
{
private:
Participants *claimant;
}
In the constructor of custom:
claimant = new Participants(ui->widget);
This uses the QWidget on the view as the parent so that's where it gets rendered. Then in a function to populate the fields I used this:
claimant->setName(recieved->getClaimant().getName());
The getName function is a function in a class that gets the name field for a person class I made. The setName is in the Paricipants widget that populates a lineEdit.
void Participants::setName(std::string str)
{
ui->nameLineEditPar->setText(QString::fromStdString(str));
}
Hope this helps anyone struggling with Qt. Any suggestion on other ways, or improvements would be gladly appreciated.
No comments:
Post a Comment