I am having a QListView which has 5 items in it. say(America, Canada, Denmark, Egypt, Finland) in my QListView. Now i want to set a common Header for all this items as COUNTRIES. How can i set a Header to a QListView. Please Help.
Well, you can not directly but, you can do this.
mHb = new QHBoxLayout;
{
QVBoxLayout *tInnerVB = new QVBoxLayout;
{
QLabel *tHeader = new QLabel("Team List");
tHeader->setFont(QFont("FontAwesome"));
tInnerVB->addWidget(tHeader);
mTeamViewModel->setStringList(BDatabase::instance()->getTeamList());
mLeTeamList->setModel(mTeamViewModel);
tInnerVB->addWidget(mLeTeamList);
}
mHb->addLayout(tInnerVB);
tInnerVB = new QVBoxLayout;
{
QLabel *tHeader = new QLabel("Team Members");
tHeader->setFont(QFont("FontAwesome"));
tInnerVB->addWidget(tHeader);
mMembersViewModel->setStringList(QStringList());
mLeTeamMembers->setModel(mMembersViewModel);
tInnerVB->addWidget(mLeTeamMembers);
}
mHb->addLayout(tInnerVB);
}
The output would be like:
Moreover, you can change orientation, alignment and other things by the label. Good coding :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With