示例#1
0
QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) :
    QDialog(parent, f)
{
  this->setWindowTitle("MITK Modules");

  QVBoxLayout* layout = new QVBoxLayout();
  this->setLayout(layout);

  QTableView* tableView = new QTableView(this);
  QmitkModuleTableModel* tableModel = new QmitkModuleTableModel(tableView);
  QSortFilterProxyModel* sortProxyModel = new QSortFilterProxyModel(tableView);
  sortProxyModel->setSourceModel(tableModel);
  sortProxyModel->setDynamicSortFilter(true);
  tableView->setModel(sortProxyModel);

  tableView->verticalHeader()->hide();
  tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
  tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
  tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
  tableView->setTextElideMode(Qt::ElideMiddle);
  tableView->setSortingEnabled(true);
  tableView->sortByColumn(0, Qt::AscendingOrder);

  tableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
  tableView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
  tableView->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents);
  tableView->horizontalHeader()->setStretchLastSection(true);
  tableView->horizontalHeader()->setCascadingSectionResizes(true);

  layout->addWidget(tableView);

  QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Close);
  layout->addWidget(btnBox);

  this->resize(800, 600);

  connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
}