本文整理汇总了C++中QList::front方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::front方法的具体用法?C++ QList::front怎么用?C++ QList::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializePage
void GitoriousRepositoryWizardPage::initializePage()
{
// Populate the model
ui->repositoryTreeView->selectionModel()->clearSelection();
if (const int oldRowCount = m_model->rowCount())
m_model->removeRows(0, oldRowCount);
ui->filterLineEdit->clear();
// fill model
const QSharedPointer<GitoriousProject> proj = m_projectPage->project();
setSubTitle(tr("Choose a repository of the project '%1'.").arg(proj->name));
// Create a hierarchical list by repository type, sort by type
QList<GitoriousRepository> repositories = proj->repositories;
QStandardItem *firstEntry = 0;
if (!repositories.empty()) {
int lastRepoType = -1;
QStandardItem *header = 0;
qStableSort(repositories.begin(), repositories.end(), gitRepoLessThanByType);
const QString types[GitoriousRepository::PersonalRepository + 1] =
{ tr("Mainline Repositories"), tr("Clones"), tr("Baseline Repositories"), tr("Shared Project Repositories"), tr("Personal Repositories") };
foreach(const GitoriousRepository &r, repositories) {
// New Header?
if (r.type != lastRepoType || !header) {
lastRepoType = r.type;
const QList<QStandardItem *> headerRow = headerEntry(types[r.type]);
m_model->appendRow(headerRow);
header = headerRow.front();
}
// Repository row
const QList<QStandardItem *> row = repositoryEntry(r);
header->appendRow(row);
if (!firstEntry)
firstEntry = row.front();
}
}
示例2: addCustomCommand
void DlgCustomToolbarsImp::addCustomCommand(const QString& name, const QByteArray& cmd)
{
QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
Workbench* w = WorkbenchManager::instance()->active();
if (w && w->name() == std::string((const char*)data.toByteArray())) {
QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(name);
if (bars.size() != 1)
return;
if (cmd == "Separator") {
QAction* action = bars.front()->addSeparator();
action->setData(QByteArray("Separator"));
}
else {
CommandManager& mgr = Application::Instance->commandManager();
if (mgr.addTo(cmd, bars.front())) {
QAction* action = bars.front()->actions().last();
// See ToolBarManager::setup(ToolBarItem* , QToolBar* )
// We have to add the user data in order to identify the command in
// removeCustomCommand(), moveUpCustomCommand() or moveDownCustomCommand()
if (action && action->data().isNull())
action->setData(cmd);
}
}
}
}
示例3: OnSelectionChanged
void QmitkDicomInspectorView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/,
const QList<mitk::DataNode::Pointer>& nodes)
{
if (nodes.size() > 0)
{
if (nodes.front() != this->m_currentSelectedNode)
{
m_internalUpdateFlag = true;
this->m_currentSelectedNode = nodes.front();
this->m_currentSelectedData = this->m_currentSelectedNode->GetData();
m_internalUpdateFlag = false;
m_selectedNodeTime.Modified();
UpdateData();
OnSliceChangedDelayed();
}
}
else
{
if (this->m_currentSelectedNode.IsNotNull())
{
m_internalUpdateFlag = true;
this->m_currentSelectedNode = nullptr;
this->m_currentSelectedData = nullptr;
m_internalUpdateFlag = false;
m_selectedNodeTime.Modified();
UpdateData();
OnSliceChangedDelayed();
}
}
}
示例4: writeResultDefintions
void TestPJobFile::writeResultDefintions(){
PJobResultFile file;
file.setFilename("ParameterVariation.txt");
PJobResult result;
result.setName("EOP");
file.addResult(result);
result.setName("Q");
result.setUnit("dB");
file.addResult(result);
QList<PJobResultFile> resultFiles;
resultFiles << file;
PJobFile::writeResultDefinitions(resultFiles,"testWriteResultDefinitions.xml");
resultFiles = PJobFile::readResultDefintions("testWriteResultDefinitions.xml");
QCOMPARE(resultFiles.size(), 1);
PJobResultFile p = resultFiles.front();
QList<PJobResult> results = p.results();
QCOMPARE(p.filename(), QString("ParameterVariation.txt"));
QCOMPARE(results.size(), 2);
PJobResult r1 = results.front();
results.pop_front();
PJobResult r2 = results.front();
QCOMPARE(r1.name(), QString("EOP"));
QCOMPARE(r1.unit(), QString(""));
QCOMPARE(r2.name(), QString("Q"));
QCOMPARE(r2.unit(), QString("dB"));
}
示例5: writeParameterCombination
void TestPJobFile::writeParameterCombination(){
QList<PJobFileParameter> parameters;
PJobFileParameter p;
p.setName("length");
p.setValue(100.);
parameters << p;
p.setName("power");
p.setVariation(1.,15.,1.);
parameters << p;
PJobFile::writeParameterCombination(parameters, "testReadParameterCombination.xml");
parameters = PJobFile::readParameterCombination("testReadParameterCombination.xml");
QFile::remove("testReadParameterCombination.xml");
QCOMPARE(parameters.size(), 2);
PJobFileParameter p1 = parameters.front();
parameters.pop_front();
PJobFileParameter p2 = parameters.front();
QCOMPARE(p1.name(), QString("length"));
QCOMPARE(p1.isVariation(), false);
QCOMPARE(p1.value(), 100.);
QCOMPARE(p2.name(), QString("power"));
QCOMPARE(p2.isVariation(), true);
QCOMPARE(p2.minValue(), 1.);
QCOMPARE(p2.maxValue(), 15.);
QCOMPARE(p2.step(), 1.);
}
示例6: ex
void TestSpanners::spanners05()
{
MasterScore* score = readScore(DIR + "glissando-cloning02.mscx");
QVERIFY(score);
score->doLayout();
// create parts
// (copied and adapted from void TestParts::createParts() in mtest/libmscore/parts/tst_parts.cpp)
QList<Part*> parts;
parts.append(score->parts().at(0));
Score* nscore = new Score(score);
Excerpt ex(score);
ex.setPartScore(nscore);
ex.setTitle(parts.front()->longName());
ex.setParts(parts);
::createExcerpt(&ex);
QVERIFY(nscore);
nscore->setName(parts.front()->partName());
score->undo(new AddExcerpt(nscore));
QVERIFY(saveCompareScore(score, "glissando-cloning02.mscx", DIR + "glissando-cloning02-ref.mscx"));
delete score;
}
示例7: removeCustomCommand
void DlgCustomToolbarsImp::removeCustomCommand(const QString& name, const QByteArray& userdata)
{
QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
Workbench* w = WorkbenchManager::instance()->active();
if (w && w->name() == std::string((const char*)data.toByteArray())) {
QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(name);
if (bars.size() != 1)
return;
QByteArray cmd = userdata;
int numSep = 0, indexSep = 0;
if (cmd.startsWith("Separator")) {
numSep = cmd.mid(9).toInt();
cmd = "Separator";
}
QList<QAction*> actions = bars.front()->actions();
for (QList<QAction*>::ConstIterator it = actions.begin(); it != actions.end(); ++it) {
if ((*it)->data().toByteArray() == cmd) {
// if we move a separator then make sure to pick up the right one
if (numSep > 0) {
if (++indexSep < numSep)
continue;
}
bars.front()->removeAction(*it);
break;
}
}
}
}
示例8: AddWarning
SmartPointer<Expression> RegistryPersistence::ReadWhenElement(
const SmartPointer<IConfigurationElement>& parentElement,
const QString& whenElementName, const QString& id,
QList<SmartPointer<IStatus> >& warningsToLog)
{
// Check to see if we have an when expression.
const QList<IConfigurationElement::Pointer> whenElements = parentElement
->GetChildren(whenElementName);
Expression::Pointer whenExpression;
if (!whenElements.isEmpty())
{
// Check if we have too many when elements.
if (whenElements.size() > 1)
{
// There should only be one when element
AddWarning(warningsToLog,
"There should only be one when element", parentElement,
id, "whenElementName", whenElementName);
return ERROR_EXPRESSION;
}
const IConfigurationElement::Pointer whenElement = whenElements.front();
const QList<IConfigurationElement::Pointer> expressionElements = whenElement->GetChildren();
if (!expressionElements.isEmpty())
{
// Check if we have too many expression elements
if (expressionElements.size() > 1)
{
// There should only be one expression element
AddWarning(warningsToLog, "There should only be one expression element", parentElement,
id, "whenElementName", whenElementName);
return ERROR_EXPRESSION;
}
// Convert the activeWhen element into an expression.
const ElementHandler::Pointer elementHandler = ElementHandler::GetDefault();
ExpressionConverter* const converter = ExpressionConverter::GetDefault();
const IConfigurationElement::Pointer expressionElement = expressionElements.front();
try
{
whenExpression = elementHandler->Create(converter, expressionElement);
}
catch (const CoreException& /*e*/)
{
// There when expression could not be created.
AddWarning(warningsToLog, "Problem creating when element",
parentElement, id, "whenElementName", whenElementName);
return ERROR_EXPRESSION;
}
}
}
return whenExpression;
}
示例9: OnSelectionChanged
void QmitkVolumetryView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList<mitk::DataNode::Pointer> &nodes)
{
m_SelectedDataNode = nullptr;
if (!nodes.isEmpty() && dynamic_cast<mitk::Image*>(nodes.front()->GetData()))
{
m_SelectedDataNode = nodes.front();
m_ParentWidget->setEnabled(true);
}
if (m_SelectedDataNode.IsNull() || m_SelectedDataNode.GetPointer() == m_OverlayNode.GetPointer())
{
m_SelectedDataNode = nullptr;
m_ParentWidget->setEnabled(false);
return;
}
if (m_OverlayNode)
{
this->GetDataStorage()->Remove(m_OverlayNode);
m_OverlayNode = nullptr;
}
this->CreateOverlayChild();
m_Controls->m_CalcButton->setEnabled(false);
m_Controls->m_TimeSeriesButton->setEnabled(false);
m_Controls->m_SaveCsvButton->setEnabled(false);
m_Controls->m_TextEdit->clear();
mitk::Image* image = dynamic_cast<mitk::Image*>(m_SelectedDataNode->GetData());
image->Update();
if (image && image->IsInitialized())
{
if (image->GetDimension() == 4)
{
m_Controls->m_TimeSeriesButton->setEnabled(true);
}
else
{
m_Controls->m_CalcButton->setEnabled(true);
}
int minVal = (int)image->GetStatistics()->GetScalarValue2ndMin();
int maxVal = (int)image->GetStatistics()->GetScalarValueMaxNoRecompute();
if (minVal == maxVal)
--minVal;
m_Controls->m_ThresholdSlider->setMinimum(minVal);
m_Controls->m_ThresholdSlider->setMaximum(maxVal);
m_Controls->m_ThresholdSlider->setEnabled(true);
this->UpdateSlider();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
示例10: GetSizeFlags
int TabbedStackPresentation::GetSizeFlags(bool width)
{
int flags = 0;
// If there is exactly one part in the stack,
// then take into account the size flags of the part.
QList<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
if (parts.size() == 1 && parts.front() != 0)
{
flags |= parts.front()->GetSizeFlags(width);
}
return flags | StackPresentation::GetSizeFlags(width);
}
示例11: main
int main ()
{
QList<int> myQList;
myQList.push_back(77);
myQList.push_back(22);
assert(myQList.front() != 77);
// now front equals 77, and back 22
myQList.front() -= myQList.back();
assert(myQList.front() == 55);
cout << "myQList.front() is now " << myQList.front() << endl;
return 0;
}
示例12: ComputePreferredSize
int TabbedStackPresentation::ComputePreferredSize(bool width,
int availableParallel, int availablePerpendicular, int preferredResult)
{
// If there is exactly one part in the stack, this just returns the
// preferred size of the part as the preferred size of the stack.
QList<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
if (parts.size() == 1 && parts.front() != 0 && !(this->GetSite()->GetState()
== IStackPresentationSite::STATE_MINIMIZED))
{
int partSize = parts.front()->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredResult);
if (partSize == INF)
return partSize;
// Adjust preferred size to take into account tab and border trim.
int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);
if (width)
{
// PaneFolder adds some bogus tab spacing, so just find the maximum width.
partSize = std::max<int>(minSize, partSize);
}
else
{
// Add them (but only if there's enough room)
if (INF - minSize > partSize)
partSize += minSize;
}
return partSize;
}
if (preferredResult != INF || this->GetSite()->GetState()
== IStackPresentationSite::STATE_MINIMIZED)
{
int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);
if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED)
{
return minSize;
}
return std::max<int>(minSize, preferredResult);
}
return INF;
}
示例13: createFolder
void chanFileSystemDockWidget::createFolder() {
QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();
QString folderName;
QString path;
QDir dir;
folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
path = m_home + QDir::separator() + folderName;
//修改硬盘中的数据
if (!dir.mkdir(path)) {
QMessageBox::warning(this, tr("error"),
tr("make directory %1 failed").arg(folderName));
return;
}
QTreeWidgetItem* item = items.empty() ?
new QTreeWidgetItem(m_fileSystemTree) :
new QTreeWidgetItem(items.front());
item->setData(0, ITEM_TYPE_KEY, Folder);
item->setData(0, FOLDER_NAME_KEY,path);
item->setText(0, folderName);
item->setIcon(0, QIcon(resourceFileName::pFolder));
}
示例14: renameFolder
void chanFileSystemDockWidget::renameFolder() {
//之前这里一直获得的都是size == 0 原因在于context menu设置不正确
//那个错误的设置是remove folder 但是却导致了这里始终接受的items.size() == 0
QList<QTreeWidgetItem*> items = m_fileSystemTree->selectedItems();
QTreeWidgetItem* item = items.front();
//根节点不可修改名字
if (m_fileSystemTree->itemAbove(item) == NULL) {
return;
}
QString folderName;
QString path;
QDir dir;
folderName = QInputDialog::getText(this, "set folder's name", "enter name:");
path = m_home + QDir::separator() + folderName;
if (!QDir().rename(item->data(0, FOLDER_NAME_KEY).toString(), (path))) {
QMessageBox::warning(this, tr("error"),
tr("failed to rename the folder!"));
return;
}
item->setData(0, FOLDER_NAME_KEY, path);
item->setText(0, folderName);
}
示例15: computeDeleteQueryButtonClicked
void MotionPlanningFrame::computeDeleteQueryButtonClicked()
{
if (planning_scene_storage_)
{
QList<QTreeWidgetItem *> sel = ui_->planning_scene_tree->selectedItems();
if (!sel.empty())
{
QTreeWidgetItem *s = sel.front();
if (s->type() == ITEM_TYPE_QUERY)
{
std::string scene = s->parent()->text(0).toStdString();
std::string query_name = s->text(0).toStdString();
try
{
planning_scene_storage_->removePlanningQuery(scene, query_name);
}
catch (std::runtime_error &ex)
{
ROS_ERROR("%s", ex.what());
}
planning_display_->addMainLoopJob(boost::bind(&MotionPlanningFrame::computeDeleteQueryButtonClickedHelper, this, s));
}
}
}
}