本文整理汇总了C++中QTableView::setShowGrid方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setShowGrid方法的具体用法?C++ QTableView::setShowGrid怎么用?C++ QTableView::setShowGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setShowGrid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
ErrorListView::ErrorListView(QWidget* parent)
: QWidget(parent),
m_model(0)
{
m_model = new ErrorListModel(this);
QTableView* tableView = new QTableView;
tableView->setItemDelegate(new ItemDelegate);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setAlternatingRowColors(true);
tableView->setShowGrid(false);
tableView->verticalHeader()->hide();
tableView->setModel(m_model);
#ifdef STROMX_STUDIO_QT4
tableView->horizontalHeader()->setResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
tableView->horizontalHeader()->setResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#else
tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#endif // STROMX_STUDIO_QT4
QPushButton* clearButton = new QPushButton(tr("Clear error log"));
connect(clearButton, SIGNAL(clicked()), m_model, SLOT(clear()));
QHBoxLayout* buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(clearButton);
buttonLayout->addStretch();
QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->addWidget(tableView);
mainLayout->addLayout(buttonLayout);
setLayout(mainLayout);
}
示例2: QListView
/*!
Return a new viewType.
*/
QAbstractItemView *ViewsToTest::createView(const QString &viewType)
{
QAbstractItemView *view = 0;
if (viewType == "QListView_ScrollPerItem") {
view = new QListView();
view->setObjectName("QListView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
} else if (viewType == "QListView_ScrollPerPixel") {
view = new QListView();
view->setObjectName("QListView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
} else if (viewType == "QHeaderViewHorizontal") {
view = new QHeaderView(Qt::Horizontal);
view->setObjectName("QHeaderView");
} else if (viewType == "QHeaderViewVertical") {
view = new QHeaderView(Qt::Vertical);
view->setObjectName("QHeaderView");
} else if (viewType == "QTableView_ScrollPerItem") {
view = new QTableView();
view->setObjectName("QTableView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
} else if (viewType == "QTableView_ScrollPerPixel") {
view = new QTableView();
view->setObjectName("QTableView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
} else if (viewType == "QTableViewNoGrid") {
QTableView *table = new QTableView();
table->setObjectName("QTableView");
table->setShowGrid(false);
view = table;
} else if (viewType == "QTreeView_ScrollPerItem") {
view = new QTreeView();
view->setObjectName("QTreeView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
view->setSelectionBehavior(QAbstractItemView::SelectItems);
} else if (viewType == "QTreeView_ScrollPerPixel") {
view = new QTreeView();
view->setObjectName("QTreeView");
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setSelectionBehavior(QAbstractItemView::SelectItems);
}
Q_ASSERT(view);
return view;
}
示例3: GalleryView
SongView::SongView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags)
: GalleryView(parent, flags)
, model(new QGalleryQueryModel(gallery))
{
model->setRootType(QDocumentGallery::Audio);
model->addColumn(QDocumentGallery::trackNumber);
model->setHeaderData(0, Qt::Horizontal, tr("Track"));
model->addColumn(QDocumentGallery::title);
model->setHeaderData(1, Qt::Horizontal, tr("Title"));
model->addColumn(QDocumentGallery::duration);
model->setHeaderData(2, Qt::Horizontal, tr("Duration"));
model->addColumn(QDocumentGallery::artist);
model->setHeaderData(3, Qt::Horizontal, tr("Artist"));
model->addColumn(QDocumentGallery::albumArtist);
model->setHeaderData(4, Qt::Horizontal, tr("Album Artist"));
model->setSortPropertyNames(QStringList()
<< QDocumentGallery::artist
<< QDocumentGallery::albumTitle
<< QDocumentGallery::trackNumber);
QTableView *view = new QTableView;
view->setShowGrid(false);
view->verticalHeader()->setVisible(false);
view->setSelectionBehavior(QAbstractItemView::SelectRows);
view->setModel(model.data());
connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
QBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(view);
setLayout(layout);
}
示例4: createLayout
void DkFileAssociationsPreference::createLayout() {
QStringList fileFilters = Settings::param().app().openFilters;
mModel = new QStandardItemModel(this);
mModel->setObjectName("fileModel");
for (int rIdx = 1; rIdx < fileFilters.size(); rIdx++)
mModel->appendRow(getItems(fileFilters.at(rIdx), checkFilter(fileFilters.at(rIdx), Settings::param().app().browseFilters), checkFilter(fileFilters.at(rIdx), Settings::param().app().registerFilters)));
mModel->setHeaderData(0, Qt::Horizontal, tr("Filter"));
mModel->setHeaderData(1, Qt::Horizontal, tr("Browse"));
mModel->setHeaderData(2, Qt::Horizontal, tr("Register"));
QTableView* filterTableView = new QTableView(this);
filterTableView->setModel(mModel);
filterTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
filterTableView->verticalHeader()->hide();
//filterTableView->horizontalHeader()->hide();
filterTableView->setShowGrid(false);
filterTableView->resizeColumnsToContents();
filterTableView->resizeRowsToContents();
filterTableView->setWordWrap(false);
QPushButton* openDefault = new QPushButton(tr("Set as Default Viewer"), this);
openDefault->setObjectName("openDefault");
// now the final widgets
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(filterTableView);
#ifdef Q_OS_WIN
layout->addWidget(openDefault);
#else
openDefault->hide();
#endif
}
示例5: QTableView
/* we create a table that has a fixed height, but can stretch to fit certain width */
QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW)
{
// setup a new table
QTableView *table = new QTableView();
QHeaderView *vHeader = table->verticalHeader();
QHeaderView *hHeader = table->horizontalHeader();
table->setAttribute(Qt::WA_DontShowOnScreen);
table->setSelectionMode(QAbstractItemView::NoSelection);
table->setFocusPolicy(Qt::NoFocus);
table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
hHeader->setVisible(false);
vHeader->setVisible(false);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
hHeader->setResizeMode(QHeaderView::Fixed);
vHeader->setResizeMode(QHeaderView::Fixed);
#else
hHeader->setSectionResizeMode(QHeaderView::Fixed);
vHeader->setSectionResizeMode(QHeaderView::Fixed);
#endif
// set the model
table->setModel(model);
/* setup cell span for the table using QTableView::setSpan().
* changes made here reflect on ProfilePrintModel::data(). */
const int cols = model->columnCount();
const int rows = model->rowCount();
// info on top
table->setSpan(0, 0, 1, 4);
table->setSpan(1, 0, 1, 4);
// gas used
table->setSpan(2, 0, 1, 2);
table->setSpan(3, 0, 1, 2);
// notes
table->setSpan(6, 0, 1, 5);
table->setSpan(7, 0, 5, 5);
/* resize row heights to the 'profilePrintRowHeights' indexes.
* profilePrintTableMaxH will then hold the table height. */
int i;
profilePrintTableMaxH = 0;
for (i = 0; i < rows; i++) {
int h = profilePrintRowHeights.at(i);
profilePrintTableMaxH += h;
vHeader->resizeSection(i, h);
}
// resize columns. columns widths are percentages from the table width.
int accW = 0;
for (i = 0; i < cols; i++) {
int pw = qCeil((qreal)(profilePrintColumnWidths.at(i) * tableW) / 100.0);
accW += pw;
if (i == cols - 1 && accW > tableW) /* adjust last column */
pw -= accW - tableW;
hHeader->resizeSection(i, pw);
}
// resize
table->resize(tableW, profilePrintTableMaxH);
// hide the grid and set a stylesheet
table->setItemDelegate(new ProfilePrintDelegate(this));
table->setShowGrid(false);
table->setStyleSheet(
"QTableView { border: none }"
"QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }");
// return
return table;
}