本文整理汇总了C++中QTreeWidget::header方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidget::header方法的具体用法?C++ QTreeWidget::header怎么用?C++ QTreeWidget::header使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget::header方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showColumnsContextMenu
void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree)
{
QMenu headerMenu(xi18nc("@title:menu", "Columns"));
QHeaderView* header = tree.header();
for (qint32 i = 0; i < tree.model()->columnCount(); i++) {
const int idx = header->logicalIndex(i);
const QString text = tree.model()->headerData(idx, Qt::Horizontal).toString();
QAction* action = headerMenu.addAction(text);
action->setCheckable(true);
action->setChecked(!header->isSectionHidden(idx));
action->setData(idx);
action->setEnabled(idx > 0);
}
QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p));
if (action != nullptr) {
const bool hidden = !action->isChecked();
tree.setColumnHidden(action->data().toInt(), hidden);
if (!hidden)
tree.resizeColumnToContents(action->data().toInt());
}
}
示例2: imageSearch
//.........这里部分代码省略.........
if (!mVisibilityIconVisibleForAssets)
return;
if (!assetItem)
return;
// Set the icon
QImage imageVis;
if (visible)
imageVis = QImage(mIconDir + TOOL_SCENEVIEW_ICON_VISIBLE);
else
imageVis = QImage(mIconDir + TOOL_SCENEVIEW_ICON_INVISIBLE);
QPixmap pixMapVis = QPixmap::fromImage(imageVis).scaled(TOOL_SCENEVIEW_ICON_WIDTH, TOOL_SCENEVIEW_ICON_WIDTH);
assetItem->setData(TOOL_SCENEVIEW_COLUMN_ASSET_VISIBILITY, Qt::DecorationRole, QVariant(pixMapVis));
// Set the visibility flag
assetItem->setData(TOOL_SCENEVIEW_KEY_VISIBLE, Qt::UserRole, QVariant(visible));
// Signal that visibility of a group is changed
emit groupVisibiltyChanged(getCurrentVisibleScene(), getGroupIdOfGroupItem(assetItem));
}
//****************************************************************************/
void QtSceneViewWidget::handleDeletionOfGroup(QTreeWidget* sceneView, QTreeWidgetItem* groupItem)
{
if (!mDeletionIconVisibleForGroups)
return;
if (!groupItem)
return;
int groupId = getGroupIdOfGroupItem(groupItem);
handleDeletionOfItem(sceneView, groupItem);
// Emit signal
emit groupDeleted(sceneView, groupId);
emit groupDeleted(getSceneId(sceneView), groupId);
}
//****************************************************************************/
void QtSceneViewWidget::handleDeletionOfAsset(QTreeWidget* sceneView, QTreeWidgetItem* assetItem)
{
if (!mDeletionIconVisibleForAssets)
return;
if (!assetItem)
return;
int groupId = getGroupIdOfAssetItem(assetItem);
int assetId = getAssetIdOfAssetItem(assetItem);
handleDeletionOfItem(sceneView, assetItem);
// Emit signal
emit assetDeleted(sceneView, groupId, assetId);
emit assetDeleted(getSceneId(sceneView), groupId, assetId);
}
//****************************************************************************/
void QtSceneViewWidget::handleDeletionOfItem(QTreeWidget* sceneView, QTreeWidgetItem* item)
{
if (!item)
return;
int index = sceneView->indexOfTopLevelItem(item);
sceneView->takeTopLevelItem(index);
delete item;
}
//****************************************************************************/
QTreeWidget* QtSceneViewWidget::createSceneView (int sceneId)
{
// Create tree
QTreeWidget* sceneView = new QTreeWidget(this);
sceneView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
sceneView->setAnimated(true);
sceneView->setEditTriggers(QAbstractItemView::NoEditTriggers);
sceneView->setDragEnabled(true);
sceneView->viewport()->installEventFilter(this);
// Set headers
QStringList headers;
headers << tr("") << tr("Asset Group") << tr("Visibility") << tr("Remove");
sceneView->setHeaderLabels(headers);
QFont font;
font.setBold(true);
sceneView->header()->setFont(font);
// Add it to the map
mSceneViewMap[sceneId] = sceneView;
// Add the groups
foreach (QtAssetGroup* group , mAssetGroupMap)
addGroupToSceneView (sceneView, group->groupIcon, group->groupId, group->groupName);
// Layout
mTreeLayout->addWidget(sceneView);
setVisibilitySearchWidgets(true);
return sceneView;
}
示例3: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStringList args = QApplication::arguments();
if (args.count() < 2) {
std::cerr << "Usage: saxhandler file1.xml..." << std::endl;
return 1;
}
QStringList labels;
labels << QObject::tr("Terms") << QObject::tr("Pages");
QTreeWidget treeWidget;
treeWidget.setHeaderLabels(labels);
treeWidget.header()->setResizeMode(QHeaderView::Stretch);
treeWidget.setWindowTitle(QObject::tr("SAX Handler"));
treeWidget.show();
SaxHandler handler(&treeWidget);
for (int i = 1; i < args.count(); ++i)
handler.readFile(args[i]);
return app.exec();
}
示例4: QWidget
QWidget *PluginAboutPage::createPage(QWidget *parent)
{
if (!m_Spec)
return new QWidget(parent);
QWidget *w = new QWidget(parent);
QVBoxLayout *layout = new QVBoxLayout(w);
layout->setSpacing(0);
layout->setMargin(0);
QTreeWidget *tree = new QTreeWidget(w);
tree->header()->hide();
layout->addWidget(tree);
QLabel *lbl = new QLabel(w);
lbl->setText(tkTr(Trans::Constants::DESCRIPTION));
layout->addWidget(lbl);
QTextBrowser *tb = new QTextBrowser(w);
layout->addWidget(tb);
// popuplate tree
tree->clear();
QFont f;
f.setBold(true);
QTreeWidgetItem *i = 0;
i = new QTreeWidgetItem(tree, QStringList() << tkTr(Trans::Constants::INFORMATION));
i->setFont(0,f);
new QTreeWidgetItem(i, QStringList() << tkTr(Trans::Constants::VERSION) + " " + m_Spec->version() );
if (Utils::isDebugWithoutInstallCompilation()) {
new QTreeWidgetItem( i, QStringList() << tkTr(Trans::Constants::BUILD_DEBUG) + " - no install");
} else {
new QTreeWidgetItem( i, QStringList() << tkTr(Trans::Constants::BUILD_RELEASE) );
}
new QTreeWidgetItem(i, QStringList() << "License: " + m_Spec->license());
tree->expandAll();
// populate textbrowser
tb->setPlainText(m_Spec->description());
return w;
}
示例5: nCols
SimpleQTreeWidgetWidthInterface::SimpleQTreeWidgetWidthInterface(QTreeWidget& tbl) : TableWidthInterface(tbl.columnCount()), m_tbl(tbl)
{
int nCols (m_tbl.columnCount());
m_vbBold.resize(nCols);
QFont font (m_tbl.font());
font.setBold(true);
QFontMetrics fontMetrics (font);
QHeaderView* pHdr (tbl.header());
for (int j = 0; j < nCols; ++j)
{
if (pHdr->isSectionHidden(j))
{
setFixedWidth(j, 0);
}
else
{
m_vnHdrWidth[j] = fontMetrics.width(m_tbl.headerItem()->text(j)) + 8/*2*QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth)*/; // PM_DefaultFrameWidth is not THE thing to use, but it's one way to get some spacing for the header; (well it turned up to be too small, so it got replaced by 8; probably look at the source to see what should be used)
}
}
}
示例6: setupUI
void VVimIndicator::setupUI()
{
m_cmdLineEdit = new VVimCmdLineEdit(this);
m_cmdLineEdit->setProperty("VimCommandLine", true);
connect(m_cmdLineEdit, &VVimCmdLineEdit::commandCancelled,
this, [this](){
if (m_editTab) {
m_editTab->focusTab();
}
// NOTICE: m_cmdLineEdit should not hide itself before setting
// focus to edit tab.
m_cmdLineEdit->hide();
if (m_vim) {
m_vim->processCommandLineCancelled();
}
});
connect(m_cmdLineEdit, &VVimCmdLineEdit::commandFinished,
this, [this](VVim::CommandLineType p_type, const QString &p_cmd){
if (m_editTab) {
m_editTab->focusTab();
}
m_cmdLineEdit->hide();
// Hide the cmd line edit before execute the command.
// If we execute the command first, we will get Chinese input
// method enabled after returning to read mode.
if (m_vim) {
m_vim->processCommandLine(p_type, p_cmd);
}
});
connect(m_cmdLineEdit, &VVimCmdLineEdit::commandChanged,
this, [this](VVim::CommandLineType p_type, const QString &p_cmd){
if (m_vim) {
m_vim->processCommandLineChanged(p_type, p_cmd);
}
});
connect(m_cmdLineEdit, &VVimCmdLineEdit::requestNextCommand,
this, [this](VVim::CommandLineType p_type, const QString &p_cmd){
if (m_vim) {
QString cmd = m_vim->getNextCommandHistory(p_type, p_cmd);
if (!cmd.isNull()) {
m_cmdLineEdit->setCommand(cmd);
} else {
m_cmdLineEdit->restoreUserLastInput();
}
}
});
connect(m_cmdLineEdit, &VVimCmdLineEdit::requestPreviousCommand,
this, [this](VVim::CommandLineType p_type, const QString &p_cmd){
if (m_vim) {
QString cmd = m_vim->getPreviousCommandHistory(p_type, p_cmd);
if (!cmd.isNull()) {
m_cmdLineEdit->setCommand(cmd);
}
}
});
connect(m_cmdLineEdit, &VVimCmdLineEdit::requestRegister,
this, [this](int p_key, int p_modifiers){
if (m_vim) {
QString val = m_vim->readRegister(p_key, p_modifiers);
if (!val.isEmpty()) {
m_cmdLineEdit->setText(m_cmdLineEdit->text() + val);
}
}
});
m_cmdLineEdit->hide();
m_modeLabel = new QLabel(this);
m_modeLabel->setProperty("VimIndicatorModeLabel", true);
QTreeWidget *regTree = new QTreeWidget(this);
regTree->setProperty("ItemBorder", true);
regTree->setRootIsDecorated(false);
regTree->setColumnCount(2);
regTree->header()->setStretchLastSection(true);
QStringList headers;
headers << tr("Register") << tr("Value");
regTree->setHeaderLabels(headers);
m_regBtn = new VButtonWithWidget("\"",
regTree,
this);
m_regBtn->setToolTip(tr("Registers"));
m_regBtn->setProperty("StatusBtn", true);
m_regBtn->setFocusPolicy(Qt::NoFocus);
connect(m_regBtn, &VButtonWithWidget::popupWidgetAboutToShow,
this, &VVimIndicator::updateRegistersTree);
QTreeWidget *markTree = new QTreeWidget(this);
markTree->setProperty("ItemBorder", true);
markTree->setRootIsDecorated(false);
//.........这里部分代码省略.........
示例7: if
//.........这里部分代码省略.........
//contacts (8) & contact_groups (14)
r=4;
mainGrid->addWidget(new QLabel("Contacts:",this),r,0);
QComboBox* contactBox = new QComboBox(this);
contactBox->addItems(listOfStringLists.at(k).at(8).split(","));
mainGrid->addWidget(contactBox,r,1,1,2);
r=5;
mainGrid->addWidget(new QLabel("Groups:",this),r,0);
QComboBox* contactGroupBox = new QComboBox(this);
contactGroupBox->addItems(listOfStringLists.at(k).at(14).split(","));
mainGrid->addWidget(contactGroupBox,r,1,1,2);
// Hostgroups (17)
r=6;
mainGrid->addWidget(new QLabel("Hostgroups:",this),r,0);
QComboBox* hostGroupBox = new QComboBox(this);
hostGroupBox->addItems(listOfStringLists.at(k).at(17).split(","));
mainGrid->addWidget(hostGroupBox,r,1,1,2);
r=7;
mainGrid->addWidget(new QLabel(" ",this),r,0);
r=8;
mainGrid->addWidget(new QLabel("Services:",this),r,0);
r=9;
//services_with_state (7)
QTreeWidget* serviceTree = new QTreeWidget(this);
serviceTree->setSelectionMode(QAbstractItemView::SingleSelection);
serviceTree->setColumnCount(2);
serviceTree->setMaximumWidth(600);
serviceTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
QStringList headerLabelsService;
headerLabelsService << "Service" << "Output";
serviceTree->setHeaderLabels(headerLabelsService);
serviceTree->setSortingEnabled (false);
mainGrid->addWidget(serviceTree,r,0,1,5);
//QStringList listServices = QString(listOfStringLists.at(k).at(7)).contains();
QStringList ServiceList;
QStringList StateList;
QStringList OutputList;
// lets get the services (ugly format)
QString state_with_info="," + QString(listOfStringLists.at(k).at(7));
QRegularExpression re("(,(\\w|\\d|/|:| )+\\|)");
QRegularExpressionMatchIterator i = re.globalMatch(state_with_info);
while (i.hasNext())
{
QRegularExpressionMatch match = i.next();
// Lets create a String List with Service name
ServiceList << match.captured(0).remove(",").remove("|");
//Here comes the trick, just remove what we just found, we need it nomore, but don't removw the seperating pipe
state_with_info.remove(match.captured(0).remove("|"));
qDebug()<< "use match" << match.captured(0);
}
qDebug() << "state_with_info" << state_with_info;
示例8: itemActivated
//slot
void KShortcutsEditorDelegate::itemActivated(QModelIndex index)
{
//As per our constructor our parent *is* a QTreeWidget
QTreeWidget *view = static_cast<QTreeWidget *>(parent());
KShortcutsEditorItem *item = KShortcutsEditorPrivate::itemFromIndex(view, index);
if (!item) {
//that probably was a non-leaf (type() !=ActionItem) item
return;
}
int column = index.column();
if (column == Name) {
// If user click in the name column activate the (Global|Local)Primary
// column if possible.
if (!view->header()->isSectionHidden(LocalPrimary)) {
column = LocalPrimary;
} else if (!view->header()->isSectionHidden(GlobalPrimary)) {
column = GlobalPrimary;
} else {
// do nothing.
}
index = index.sibling(index.row(), column);
view->selectionModel()->select(index, QItemSelectionModel::SelectCurrent);
}
// Check if the models wants us to edit the item at index
if (!index.data(ShowExtensionIndicatorRole).value<bool>()) {
return;
}
if (!isExtended(index)) {
//we only want maximum ONE extender open at any time.
if (m_editingIndex.isValid()) {
KShortcutsEditorItem *oldItem = KShortcutsEditorPrivate::itemFromIndex(view,
m_editingIndex);
Q_ASSERT(oldItem); //here we really expect nothing but a real KShortcutsEditorItem
oldItem->setNameBold(false);
contractItem(m_editingIndex);
}
m_editingIndex = index;
QWidget *viewport = static_cast<QAbstractItemView *>(parent())->viewport();
if (column >= LocalPrimary && column <= GlobalAlternate) {
ShortcutEditWidget *editor = new ShortcutEditWidget(viewport,
index.data(DefaultShortcutRole).value<QKeySequence>(),
index.data(ShortcutRole).value<QKeySequence>(),
m_allowLetterShortcuts);
if (column == GlobalPrimary) {
QObject *action = index.data(ObjectRole).value<QObject *>();
editor->setAction(action);
editor->setMultiKeyShortcutsAllowed(false);
QString componentName = action->property("componentName").toString();
if (componentName.isEmpty()) {
componentName = QCoreApplication::applicationName();
}
editor->setComponentName(componentName);
}
m_editor = editor;
// For global shortcuts check against the kde standard shortcuts
if (column == GlobalPrimary || column == GlobalAlternate) {
editor->setCheckForConflictsAgainst(
KKeySequenceWidget::LocalShortcuts
| KKeySequenceWidget::GlobalShortcuts
| KKeySequenceWidget::StandardShortcuts);
}
editor->setCheckActionCollections(m_checkActionCollections);
connect(m_editor, SIGNAL(keySequenceChanged(QKeySequence)),
this, SLOT(keySequenceChanged(QKeySequence)));
connect(m_editor, SIGNAL(stealShortcut(QKeySequence,QAction*)),
this, SLOT(stealShortcut(QKeySequence,QAction*)));
} else if (column == RockerGesture) {
示例9: addCertButton
SignatureDialog::SignatureDialog( const DigiDocSignature &signature, QWidget *parent )
: QDialog( parent )
, s( signature )
, d( new SignatureDialogPrivate )
{
d->setupUi( this );
d->error->hide();
setAttribute( Qt::WA_DeleteOnClose );
const SslCertificate c = s.cert();
#define addCertButton(cert, button) if(!cert.isNull()) \
d->buttonBox->addButton(button, QDialogButtonBox::ActionRole)->setProperty("cert", QVariant::fromValue(cert));
addCertButton(s.cert(), tr("Show signer's certificate"));
addCertButton(s.ocspCert(), tr("Show OCSP certificate"));
addCertButton(s.tsaCert(), tr("Show TSA certificate"));
addCertButton(qApp->confValue( Application::TSLCert ).value<QSslCertificate>(), tr("Show TSL certificate"));
QString status;
switch( s.validate() )
{
case DigiDocSignature::Valid:
status = tr("Signature is valid");
break;
case DigiDocSignature::Warning:
status = QString("%1 (%2)").arg( tr("Signature is valid"), tr("Warnings") );
if( !s.lastError().isEmpty() )
d->error->setPlainText( s.lastError() );
if( s.warning() & DigiDocSignature::WrongNameSpace )
{
d->info->setText( tr(
"This Digidoc document has not been created according to specification, "
"but the digital signature is legally valid. Please inform the document creator "
"of this issue. <a href='http://www.id.ee/?id=36511'>Additional information</a>.") );
}
if( s.warning() & DigiDocSignature::DigestWeak )
{
d->info->setText( tr(
"The current BDOC container uses weaker encryption method than officialy accepted in Estonia.") );
}
break;
case DigiDocSignature::Test:
status = QString("%1 (%2)").arg( tr("Signature is valid"), tr("Test signature") );
if( !s.lastError().isEmpty() )
d->error->setPlainText( s.lastError() );
d->info->setText( tr(
"Test signature is signed with test certificates that are similar to the "
"certificates of real tokens, but digital signatures with legal force cannot "
"be given with them as there is no actual owner of the card. "
"<a href='http://www.id.ee/index.php?id=30494'>Additional information</a>.") );
break;
case DigiDocSignature::Invalid:
status = tr("Signature is not valid");
d->error->setPlainText( s.lastError().isEmpty() ? tr("Unknown error") : s.lastError() );
d->info->setText( tr(
"This is an invalid signature or malformed digitally signed file. The signature is not valid.") );
break;
case DigiDocSignature::Unknown:
status = tr("Signature status unknown");
d->error->setPlainText( s.lastError().isEmpty() ? tr("Unknown error") : s.lastError() );
d->info->setText( tr(
"Signature status is displayed unknown if you don't have all validity confirmation service "
"certificates and/or certificate authority certificates installed into your computer. "
"<a href='http://www.id.ee/index.php?id=35941'>Additional information</a>.") );
break;
}
if( d->error->toPlainText().isEmpty() && d->info->text().isEmpty() )
d->tabWidget->removeTab( 0 );
else
d->buttonBox->addButton( QDialogButtonBox::Help );
d->title->setText( c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ) + "\n" + status );
setWindowTitle( c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ) + " - " + status );
const QStringList l = s.locations();
d->signerCity->setText( l.value( 0 ) );
d->signerState->setText( l.value( 1 ) );
d->signerZip->setText( l.value( 2 ) );
d->signerCountry->setText( l.value( 3 ) );
Q_FOREACH( const QString &role, s.roles() )
{
QLineEdit *line = new QLineEdit( role, d->signerRoleGroup );
line->setReadOnly( true );
d->signerRoleGroupLayout->addRow( line );
}
// Certificate info
QTreeWidget *t = d->signatureView;
t->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
addItem( t, tr("TSL URL"), qApp->confValue( Application::TSLUrl ).toString() );
addItem( t, tr("Signer's computer time (UTC)"), DateTime( s.signTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
addItem( t, tr("Signature method"), s.signatureMethod() );
addItem( t, tr("Container format"), s.parent()->mediaType() );
if( s.type() != DigiDocSignature::DDocType )
addItem( t, tr("Signature format"), s.profile() );
if( !s.policy().isEmpty() )
{
#define toVer(X) (X)->toUInt() - 1
QStringList ver = s.policy().split( "." );
if( ver.size() >= 3 )
addItem( t, tr("Signature policy"), QString("%1.%2.%3").arg( toVer(ver.end()-3) ).arg( toVer(ver.end()-2) ).arg( toVer(ver.end()-1) ) );
//.........这里部分代码省略.........
示例10: GenAdjustWidgetAppearanceToOS
void QtHelpers::GenAdjustWidgetAppearanceToOS(QWidget *rootWidget)
{
if (rootWidget == NULL)
return;
QObject *child = NULL;
QObjectList Containers;
QObject *container = NULL;
QStringList DoNotAffect;
// Make an exception list (Objects not to be affected)
DoNotAffect.append("aboutTitleLabel"); // about Dialog
DoNotAffect.append("aboutVersionLabel"); // about Dialog
DoNotAffect.append("aboutCopyrightLabel"); // about Dialog
DoNotAffect.append("aboutUrlLabel"); // about Dialog
DoNotAffect.append("aboutLicenseLabel"); // about Dialog
// Set sizes according to OS:
#ifdef __APPLE__
int ButtonHeight = 35;
int cmbxHeight = 30;
QFont cntrlFont("Myriad Pro", 14);
QFont txtFont("Myriad Pro", 14);
#elif _WIN32 // Win XP/7
int ButtonHeight = 24;
int cmbxHeight = 20;
QFont cntrlFont("MS Shell Dlg 2", 8);
QFont txtFont("MS Shell Dlg 2", 8);
#else
int ButtonHeight = 24;
int cmbxHeight = 24;
QFont cntrlFont("Ubuntu Condensed", 10);
QFont txtFont("Ubuntu", 10);
#endif
// Append root to containers
Containers.append(rootWidget);
while (!Containers.isEmpty())
{
container = Containers.takeFirst();
if (container != NULL)
{
for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++)
{
child = container->children()[ChIdx];
if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
continue;
// Append containers to Stack for recursion
if (child->children().size() > 0)
Containers.append(child);
else
{
// Cast child object to button and label
// (if the object is not of the correct type, it will be NULL)
QPushButton *button = qobject_cast<QPushButton *>(child);
QLabel *label = qobject_cast<QLabel *>(child);
QComboBox *cmbx = qobject_cast<QComboBox *>(child);
QLineEdit *ln = qobject_cast<QLineEdit *>(child);
QTreeWidget *tree = qobject_cast<QTreeWidget *>(child);
QPlainTextEdit *plain = qobject_cast<QPlainTextEdit *>(child);
QCheckBox *check = qobject_cast<QCheckBox *>(child);
if (button != NULL)
{
button->setMinimumHeight(ButtonHeight); // Win
button->setMaximumHeight(ButtonHeight); // Win
button->setFont(cntrlFont);
}
else if (cmbx != NULL)
{
cmbx->setFont(cntrlFont);
cmbx->setMaximumHeight(cmbxHeight);
}
else if (label != NULL)
label->setFont(txtFont);
else if (ln != NULL)
ln->setFont(txtFont);
else if (tree != NULL)
{
tree->header()->setFont(txtFont);
}
else if (plain != NULL)
plain->setFont(txtFont);
else if (check != NULL)
check->setFont(txtFont);
}
}
}
}
}