当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeWidget::insertTopLevelItem方法代码示例

本文整理汇总了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();
        }
    }
开发者ID:npapier,项目名称:vgsdk,代码行数:28,代码来源:MultiFieldEditor.hpp

示例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();
        }
    }
开发者ID:npapier,项目名称:vgsdk,代码行数:34,代码来源:MultiFieldEditor.hpp

示例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();
    }
开发者ID:npapier,项目名称:vgsdk,代码行数:26,代码来源:MultiFieldEditor.hpp

示例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);
    }
}
开发者ID:hipopotamo-hipotalamo,项目名称:appleseed,代码行数:17,代码来源:treewidget.cpp

示例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);
}
开发者ID:IPAM-IGF,项目名称:VesselMod,代码行数:19,代码来源:Box.cpp

示例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);
开发者ID:eastcoastkiter,项目名称:whassup,代码行数:67,代码来源:hostinfowidget.cpp

示例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);

}
开发者ID:LMiceOrg,项目名称:Modelingtools,代码行数:70,代码来源:outputwindow.cpp

示例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);

}
开发者ID:BastienCramillet,项目名称:SGC,代码行数:81,代码来源:ScriptingArea.cpp

示例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();
}
开发者ID:draekko,项目名称:hydrogen,代码行数:32,代码来源:PlaylistDialog.cpp


注:本文中的QTreeWidget::insertTopLevelItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。