本文整理汇总了C++中QTreeWidget::insertTopLevelItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidget::insertTopLevelItem方法的具体用法?C++ QTreeWidget::insertTopLevelItem怎么用?C++ QTreeWidget::insertTopLevelItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget::insertTopLevelItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveDownClicked
void moveDownClicked()
{
QList<QTreeWidgetItem*> selectedPaths = m_treeView->selectedItems();
if( selectedPaths.isEmpty() )
{
return;
}
else if( m_treeView->indexOfTopLevelItem(selectedPaths.last()) == m_treeView->topLevelItemCount() -1)
{
return;
}
else
{
// Retrieves the value that is before the first selected row.
int index = m_treeView->indexOfTopLevelItem( selectedPaths.last() );
QTreeWidgetItem* newRow = m_treeView->takeTopLevelItem(index);
newRow->setFlags(newRow->flags() | Qt::ItemIsEditable);
m_treeView->insertTopLevelItem( index + 1, newRow);
newRow->setSelected(true);
m_treeView->topLevelItem(index)->setSelected(false);
rebuildRowIndexes();
// Sends a change notification.
Q_EMIT signalChanged();
}
}
示例2: moveUpClicked
void moveUpClicked()
{
QList<QTreeWidgetItem*> selectedPaths = m_treeView->selectedItems();
if( selectedPaths.isEmpty() )
{
return;
}
else if( m_treeView->indexOfTopLevelItem(selectedPaths.last()) == 0 )
{
return;
}
else
{
int index = m_treeView->indexOfTopLevelItem( selectedPaths.last() );
QTreeWidgetItem* newRow = m_treeView->takeTopLevelItem(index);
if(index < m_treeView->topLevelItemCount())
{
m_treeView->topLevelItem(index)->setSelected(false);
}
else
{
m_treeView->topLevelItem(m_treeView->topLevelItemCount() - 1 )->setSelected(false);
}
newRow->setFlags(newRow->flags() | Qt::ItemIsEditable);
m_treeView->insertTopLevelItem( index - 1, newRow);
newRow->setSelected(true);
rebuildRowIndexes();
// Sends a change notification.
Q_EMIT signalChanged();
}
}
示例3: addClicked
//@{
void addClicked()
{
QTreeWidgetItem *newRow = 0;
QList<QTreeWidgetItem*> selectedPaths = m_treeView->selectedItems();
if(selectedPaths.empty())
{
newRow = new QTreeWidgetItem( m_treeView );
}
else
{
newRow = new QTreeWidgetItem();
m_treeView->insertTopLevelItem(m_treeView->indexOfTopLevelItem(selectedPaths.last()) + 1, newRow);
}
if(newRow)
{
newRow->setFlags(newRow->flags() | Qt::ItemIsEditable);
m_adapter.updateToRow(newRow, typename MFAdapter::value_type());
updateLabel();
rebuildRowIndexes();
}
Q_EMIT signalChanged();
}
示例4: move_to_sorted_position
void move_to_sorted_position(QTreeWidgetItem* item)
{
assert(item);
if (item->parent())
{
QTreeWidgetItem* parent = item->parent();
parent->removeChild(item);
parent->insertChild(find_sorted_position(parent, item->text(0)), item);
}
else if (item->treeWidget())
{
QTreeWidget* parent = item->treeWidget();
parent->takeTopLevelItem(parent->indexOfTopLevelItem(item));
parent->insertTopLevelItem(find_sorted_position(parent, item->text(0)), item);
}
}
示例5: updateContainerTree
void Box::updateContainerTree(QTreeWidget & qt){
qt.clear();
QTreeWidgetItem* item=new QTreeWidgetItem();
item->setIcon(0, QIcon(QString::fromUtf8(":/ico/box.png")));
item->setText(0, (std::string("Box ")+to_string(this)).c_str());
QTreeWidgetItem* itemWidth=new QTreeWidgetItem(item);
itemWidth->setText(0, (std::string("Width : ")+to_string(getWidth())).c_str());
itemWidth->setIcon(0, QIcon(QString::fromUtf8(":/ico/axis.png")));
QTreeWidgetItem* itemHeight=new QTreeWidgetItem(item);
itemHeight->setText(0, (std::string("Height : ")+to_string(getHeight())).c_str());
itemHeight->setIcon(0, QIcon(QString::fromUtf8(":/ico/axis.png")));
QTreeWidgetItem* itemDepth=new QTreeWidgetItem(item);
itemDepth->setText(0, (std::string("Depth : ")+to_string(getDepth())).c_str());
itemDepth->setIcon(0, QIcon(QString::fromUtf8(":/ico/axis.png")));
QTreeWidgetItem* itemNCells=new QTreeWidgetItem(item);
itemNCells->setText(0, (std::string("Cells : ")+to_string(cells.size())).c_str());
itemNCells->setIcon(0, QIcon(QString::fromUtf8(":/ico/cells.gif")));
qt.insertTopLevelItem(0,item);
}
示例6: if
//.........这里部分代码省略.........
while (i2.hasNext())
{
QRegularExpressionMatch match = i2.next();
qDebug()<< "use match 2" << match.captured(0);
qDebug() << "state" << match.captured(0).split("|")[1];
StateList << match.captured(0).split("|")[1];
state_with_info.replace(match.captured(0),"|");
}
qDebug() << "state_with_info" << state_with_info;
// and last the output (remove first pipe
state_with_info.remove(0,1);
OutputList=state_with_info.split("|");
for (int i=0;i<ServiceList.size();i++)
{
qDebug() << "ServicesList" << i << ServiceList.at(i) << StateList.at(i) << OutputList.at(i);
QStringList tmp;
tmp << ServiceList.at(i) << OutputList.at(i);
QTreeWidgetItem* Item = new QTreeWidgetItem(tmp,QTreeWidgetItem::Type);
if (StateList.at(i) == "0")
{
Item->setIcon(0, QIcon(QPixmap(ok_xpm)) );
}
else if (StateList.at(i) == "1")
{
Item->setIcon(0, QIcon(QPixmap(warning_xpm)) );
}
else
{
Item->setIcon(0, QIcon(QPixmap(critical_xpm)) );
}
serviceTree->insertTopLevelItem(0,Item);
}
r=1;
QPushButton* browserUrlButton = new QPushButton("Open in Browser", this);
connect( browserUrlButton, SIGNAL( pressed()) , this, SLOT( browserUrlButtonPressed() ) );
mainGrid->addWidget(browserUrlButton,r,4);
r=2;
QPushButton* actionUrlButton = new QPushButton("Open Action URL", this);
connect( actionUrlButton, SIGNAL( pressed()) , this, SLOT( actionUrlButtonPressed() ) );
mainGrid->addWidget(actionUrlButton,r,4);
r=3;
QPushButton* notesUrlButton = new QPushButton("Open Notes URL", this);
connect( notesUrlButton, SIGNAL( pressed()) , this, SLOT( notesUrlButtonPressed() ) );
mainGrid->addWidget(notesUrlButton,r,4);
r=4;
QPushButton* logButton = new QPushButton("Open Log", this);
connect( logButton, SIGNAL( pressed()) , this, SLOT( logButtonPressed() ) );
mainGrid->addWidget(logButton,r,4);
//Get overallstate
//worst_service_state (18) + state (4)
int overallState=listOfStringLists.at(k).at(18).toInt()+listOfStringLists.at(k).at(4).toInt();
qDebug() << "overallState" << overallState;
r=1;
pcDialog = new PCDialog(Hostname, overallState, this);
connect( pcDialog, SIGNAL(doubleClickedHost(QString)) , this, SLOT( slotDoubleClickedHost(QString) ) );
mainGrid->addWidget(pcDialog,r,5,9,3);
示例7: px
OutputWindow::OutputWindow(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::OutputWindow)
{
ui->setupUi(this);
setAllowedAreas(Qt::AllDockWidgetAreas);
connect(ui->treeDataStruct, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(modelDataStructDblClicked(QModelIndex)) );
connect(ui->treeModelDsc, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(modelModelDscDblClicked(QModelIndex)) );
QPixmap px(":/flatastic1");
int px_width = 112, px_height = 112;
ui->tabWidget->setTabText(0, tr("Project"));
ui->tabWidget->setTabText(1, tr("Data Structure"));
ui->tabWidget->setTabText(2, tr("Model Description"));
ui->tabWidget->setTabText(3, tr("Model Code"));
ui->tabWidget->setTabIcon(0, QIcon(px.copy(0*px_width,3*px_height, px_width,px_height)));
ui->tabWidget->setTabIcon(1, QIcon(px.copy(3*px_width,3*px_height, px_width,px_height)));
ui->tabWidget->setTabIcon(2, QIcon(px.copy(4*px_width,0*px_height, px_width,px_height)));
ui->tabWidget->setTabIcon(3, QIcon(px.copy(1*px_width,0*px_height, px_width,px_height)));
xmlIcon = new QIcon(px.copy(1*px_width,2*px_height, px_width,px_height));
excelIcon = new QIcon(px.copy(4*px_width,2*px_height, px_width,px_height));
folderIcon = new QIcon(px.copy(4*px_width,4*px_height, px_width,px_height));
descIcon = new QIcon(px.copy(0*px_width,1*px_height, px_width,px_height));
modelFolder = qApp->applicationDirPath();
QTreeWidget* tree;
QTreeWidgetItem* item;
QStringList ls;
tree = ui->treeWidget;
tree->setColumnCount(1);
tree->setHeaderLabel(tr("Model Excel File"));
tree->insertTopLevelItem(0, new QTreeWidgetItem(tree, ls));
item = tree->topLevelItem(0);
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
tree = ui->treeDataStruct;
tree->setColumnCount(1);
tree->setHeaderLabel(tr("Model Data Structure"));
tree->insertTopLevelItem(0, new QTreeWidgetItem(tree, ls));
item = tree->topLevelItem(0);
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
tree = ui->treeModelDsc;
tree->setColumnCount(1);
tree->setHeaderLabel(tr("Model Description"));
tree->insertTopLevelItem(0, new QTreeWidgetItem(tree, ls));
item = tree->topLevelItem(0);
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
tree = ui->treeProject;
tree->setColumnCount(1);
tree->setHeaderLabel(tr("Model Code"));
tree->insertTopLevelItem(0, new QTreeWidgetItem(tree, ls));
item = tree->topLevelItem(0);
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
}
示例8: f
ScriptingArea::ScriptingArea(MapEditor *parent) : QDockWidget(parent) {
setWindowTitle("Zone de scripting");
// partie zone de texte
QsciLexerLua *lexerLua = new QsciLexerLua();
m_textZone.setLexer(lexerLua);
m_textZone.setUtf8(true);
m_textZone.setMarginLineNumbers(1, true); // numérotation des lignes
m_textZone.setMarginWidth(1, 30); // agrandissement de la marge
//this->setAutoCompletionSource(AcsAPIs);
//this->setAutoCompletionThreshold(1);
QsciLexerLua *lexLua= new QsciLexerLua();
QsciAPIs *api = new QsciAPIs(lexLua);
if ( ! api->load(":/ressources/autocompetion.api") ) {
Log::e("ScriptingArea") << "Erreur chargement autocompletion.api";
}
api->prepare();
m_textZone.setAutoCompletionSource(QsciScintilla::AcsAPIs);
m_textZone.setLexer(lexLua);
m_textZone.setAutoCompletionThreshold(1);
clear();
// partie arbre des fonctions possibles
QTreeWidget *treeDoc = new QTreeWidget();
treeDoc->setHeaderHidden(true);
QDomDocument doc;
QFile f(EDITOR_DATA_DIR + "/scriptingFunctions.xml");
if ( ! f.open(QIODevice::ReadOnly) ) {
Log::e("Editor") << "erreur ouverture " << f.fileName() << " : " << f.errorString();
}
doc.setContent(&f);
f.close();
QDomElement root = doc.documentElement();
QDomNode n = root.firstChild();
while( ! n.isNull() ) {
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, n.toElement().tagName());
treeDoc->insertTopLevelItem(0, item);
QDomNode instance = n.firstChild();
while ( ! instance.isNull() ) {
QTreeWidgetItem *item2 = new QTreeWidgetItem();
item2->setText(0, instance.toElement().attribute("signature"));
item->addChild(item2);
instance = instance.nextSibling();
}
n = n.nextSibling();
}
// ajout dans le layout
QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(&m_textZone);
splitter->addWidget(treeDoc);
// on agrandit le premier widget, la zone de texte
splitter->setStretchFactor(0, 0.75 * width());
QHBoxLayout *scriptingDockLayout = new QHBoxLayout();
scriptingDockLayout->addWidget(splitter);
QWidget *scriptingDockContent = new QWidget();
setWidget(scriptingDockContent);
scriptingDockContent->setLayout(scriptingDockLayout);
}
示例9: o_upBClicked
void PlaylistDialog::o_upBClicked()
{
timer->stop();
Playlist* pPlaylist = Playlist::get_instance();
QTreeWidget* pPlaylistTree = m_pPlaylistTree;
QTreeWidgetItem* pPlaylistTreeItem = m_pPlaylistTree->currentItem();
int index = pPlaylistTree->indexOfTopLevelItem ( pPlaylistTreeItem );
if (index == 0 ){
timer->start( 1000 );
return;
}
QTreeWidgetItem* tmpPlaylistItem = pPlaylistTree->takeTopLevelItem ( index );
pPlaylistTree->insertTopLevelItem ( index -1, tmpPlaylistItem );
pPlaylistTree->setCurrentItem ( tmpPlaylistItem );
if ( pPlaylist->getSelectedSongNr() >= 0 ){
pPlaylist->setSelectedSongNr( pPlaylist->getSelectedSongNr() -1 );
}
if ( pPlaylist->getActiveSongNumber() == index ){
pPlaylist->setActiveSongNumber( pPlaylist->getActiveSongNumber() -1 );
}else if ( pPlaylist->getActiveSongNumber() == index -1 ){
pPlaylist->setActiveSongNumber( pPlaylist->getActiveSongNumber() +1 );
}
updatePlayListVector();
}