Народ помогите пожалуйста выгрузить в закладки первые буквы фамилий фамилий из таблицы, а ещё нужно поместить в эти закладки фамилии начинающиеся на соответствующую букву!
FamilyTab::FamilyTab(QWidget *parent)
: QTabWidget(parent)
{
m_pAnketaModel = new QSqlRelationalTableModel(this);
m_pAnketaModel->setTable("anketa");
//m_pAnketaModel->setFilter("idperson = 1");
m_pAnketaModel->setSort(Anketa_fio,Qt::AscendingOrder);
m_pAnketaModel->setHeaderData(Anketa_fio, Qt::Horizontal, tr("ФИО"));
m_pAnketaModel->setHeaderData(Anketa_birthdate,Qt::Horizontal, tr("Дата рождения"));
m_pAnketaModel->setHeaderData(Aketa_birthplace, Qt::Horizontal, tr("Место рождения"));
m_pAnketaModel->setHeaderData(Anketa_adres, Qt::Horizontal,tr("Адрес"));
m_pAnketaModel->setHeaderData(Anketa_nomerseria,Qt::Horizontal, tr("Номер/Серия"));
m_pAnketaModel->setHeaderData(Anketa_characteristics, Qt::Horizontal, tr("Характеристика"));
m_pAnketaModel->setHeaderData(Anketa_addingdate, Qt::Horizontal, tr("Время добавления"));
m_pAnketaModel->select();
m_pAnketaView = new QTableView;
m_pAnketaView->setModel(m_pAnketaModel);
m_pAnketaView->setColumnHidden(Anketa_Id, true);
m_pAnketaView->setSelectionMode(QAbstractItemView::SingleSelection);
m_pAnketaView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pAnketaView->resizeColumnsToContents();
m_pTrackRecordModel = new QSqlTableModel(this);
m_pTrackRecordModel->setTable("workingtrack");
m_pTrackRecordModel->setHeaderData(workingplace, Qt::Horizontal, tr("Место работы"));
m_pTrackRecordModel->setHeaderData(working_enteringdate, Qt::Horizontal, tr("Дата поступления"));
m_pTrackRecordModel->setHeaderData(working_sakingdate, Qt::Horizontal, tr("Дата увольнения"));
m_pTrackRecordModel->setHeaderData(working_sakingreason, Qt::Horizontal, tr("Причина увольнения"));
//m_pTrackRecordModel->select();
m_pTrackRecordView = new QTableView;
m_pTrackRecordView->setModel(m_pTrackRecordModel);
//m_pTrackRecordView->setItemDelegate(new MyDEDelegate(working_enteringdate, this));
//m_pTrackRecordView->setItemDelegate(new MyDEDelegate(working_sakingdate, this));
m_pTrackRecordView->setSelectionMode(QAbstractItemView::SingleSelection);
m_pTrackRecordView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pTrackRecordView->resizeColumnsToContents();
// m_pList = new QListWidget;
//m_pMainLayout->addWidget(m_pList);
m_pLayout = new QGridLayout;
m_pAddButton = new QPushButton(QObject::tr("Добавить"));
m_pAddButton->setFocusPolicy(Qt::NoFocus);
m_pEditButton = new QPushButton(QObject::tr("Редактировать"));
m_pEditButton->setFocusPolicy(Qt::NoFocus);
m_pDeleteButton = new QPushButton(QObject::tr("Удалить"));
m_pDeleteButton->setFocusPolicy(Qt::NoFocus);
m_pReportButton = new QPushButton(QObject::tr("Отчёт"));
m_pReportButton->setFocusPolicy(Qt::NoFocus);
m_pOKButton = new QPushButton(QObject::tr("OK"));
m_pOKButton->setFocusPolicy(Qt::NoFocus);
m_pQuitButton = new QPushButton(QObject::tr("Выход"));
m_pQuitButton->setFocusPolicy(Qt::NoFocus);
m_pButtonLayout = new QHBoxLayout;
m_pButtonLayout->addWidget(m_pAddButton);
m_pButtonLayout->addWidget(m_pEditButton);
m_pButtonLayout->addWidget(m_pDeleteButton);
m_pButtonLayout->addWidget(m_pReportButton);
m_pButtonLayout->addWidget(m_pOKButton);
m_pButtonLayout->addWidget(m_pQuitButton);
m_pButtonLayout->addStretch();
m_pSplitter = new QSplitter(Qt::Vertical);
m_pSplitter->addWidget(m_pAnketaView);
m_pSplitter->addWidget(m_pTrackRecordView);
m_pMainLayout = new QVBoxLayout(this);
m_pMainLayout->addWidget(m_pSplitter);
m_pMainLayout->addLayout(m_pButtonLayout);
currentFamilyChanged (QModelIndex());
connect(m_pAnketaView->selectionModel(),
SIGNAL(currentRowChanged(const QModelIndex &,
const QModelIndex &)),
this, SLOT(currentFamilyChanged(const QModelIndex &)));
connect(m_pTrackRecordModel, SIGNAL(beforeInsert(QSqlRecord &)),
this, SLOT(beforeInsertTrack(QSqlRecord &)));
connect(m_pAddButton, SIGNAL(clicked()), this, SLOT(AddTrack()));
connect(m_pQuitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(m_pOKButton, SIGNAL(clicked()), this, SLOT(ApplyOK()));
connect(m_pDeleteButton, SIGNAL(clicked()), this, SLOT(deleteTrack()));
connect(m_pEditButton, SIGNAL(clicked()), this, SLOT(EditTrack()));
connect(m_pReportButton, SIGNAL(clicked()), this, SLOT(OpenReport()));
//m_pLayout->setColumnStretch(2,1);
//m_pMainLayout->addLayout(m_pLayout);
void FamilyTab::AddTabs()
{
// QSqlQuery query;
QStringList m_pList;
QString name;
//query.exec(QString("SELECT fio FROM anketa"));
// query.result() = m_pList;
name = m_pList[0];
foreach(QString word, m_pList)
{
name = word;
FamilyTab addTabs;
addTab(&addTabs, name);
}
}
Как Класс элемента с закладками я использовал QTabWidget, точнее я от него наследовался!