本文整理汇总了C++中QList::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::pop_back方法的具体用法?C++ QList::pop_back怎么用?C++ QList::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::pop_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupModelData
void SharesNavigatorTreeModel::setupModelData(const QStringList& lines, SharesNavigatorTreeItem* parent)
{
QList<SharesNavigatorTreeItem*> parents;
QList<int> indentations;
parents << parent;
indentations << 0;
int number = 0;
while(number < lines.count())
{
int position = 0;
while(position < lines[number].length())
{
if(lines[number].mid(position, 1) != " ")
{
break;
}
position++;
}
QString lineData = lines[number].mid(position).trimmed();
if(!lineData.isEmpty())
{
// Read the column data from the rest of the line.
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
QList<QVariant> columnData;
for(int column = 0; column < columnStrings.count(); ++column)
{
columnData << columnStrings[column];
}
if(position > indentations.last())
{
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if(parents.last()->childCount() > 0)
{
parents << parents.last()->child(parents.last()->childCount() - 1);
indentations << position;
}
}
else
{
while(position < indentations.last() && parents.count() > 0)
{
parents.pop_back();
indentations.pop_back();
}
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new SharesNavigatorTreeItem(columnData, parents.last()));
}
number++;
}
}
示例2: setupModelData
void TreeModel::setupModelData(const QStringList &lines,TreeItem *parent)
{
QList<TreeItem*> parents;
QList<int> indentations;
parents << parent;
indentations << 0;
int number = 0;
while (number < lines.count()) {
int position = 0;
while (position < lines[number].length()) {
if (lines[number].at(position) != ' ')
break;
position++;
}
QString lineData = lines[number].mid(position).trimmed();
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
QList<QVariant> columnData;
for (int column = 0; column < columnStrings.count(); ++column)
columnData << columnStrings[column];
if (position > indentations.last()) {
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if (parents.last()->childCount() > 0) {
parents << parents.last()->child(parents.last()->childCount()-1);
indentations << position;
}
} else {
while (position < indentations.last() && parents.count() > 0) {
parents.pop_back();
indentations.pop_back();
}
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
}
++number;
}
foreach (QString e, DataController::getInstance()->getEssences())
{
EREssenceData * data = DataController::getInstance()->search(e);
QString name = data->getId();
QString type = Support::typeToString(data->getType());
QList<QString> keys = data->getKeys();
QList<QString> attrs = data->getAttributes();
QList<QString> adj = DataController::getInstance()->getAjesencyFor(data->getId());
}
示例3: setupModelData
void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{
QList<TreeItem*> parents;
QList<int> indentations;
parents << parent;
indentations << 0;
int number = 0;
while (number < lines.count()) {
int position = 0;
while (position < lines[number].length()) {
if (lines[number].mid(position, 1) != " ")
break;
position++;
}
QString lineData = lines[number].mid(position).trimmed();
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
QVector<QVariant> columnData;
for (int column = 0; column < columnStrings.count(); ++column)
columnData << columnStrings[column];
if (position > indentations.last()) {
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if (parents.last()->childCount() > 0) {
parents << parents.last()->child(parents.last()->childCount()-1);
indentations << position;
}
} else {
while (position < indentations.last() && parents.count() > 0) {
parents.pop_back();
indentations.pop_back();
}
}
// Append a new item to the current parent's list of children.
TreeItem *parent = parents.last();
parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
for (int column = 0; column < columnData.size(); ++column)
parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
}
number++;
}
}
示例4: connect
bool Wheel::connect(QString portName)
{
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
//Locking for the port
while (!ports.isEmpty() && ports.last().portName() != portName)
{
ports.pop_back();
}
port = &ports.last();
serial->setPort(*port);
serial->readAll(); // Clear buffer
if (serial->open(QIODevice::ReadWrite)) {
serial->setDataTerminalReady(false); // Set DTR to low to reset the arduino board.
serial->setDataTerminalReady(true);
//Initialisation sequence
serial->waitForReadyRead(3000);
char data[7]; // Read buffer
serial->read(data, sizeof(wheel_con_report_t));
wheel_con_report_t w_info;
memcpy(&w_info, data, sizeof(wheel_con_report_t));
if (w_info.bDescriptorType == 0x01) { // Device is identified, it seems to be an arduwheel
vFirmware = QString::fromUtf8(w_info.vFirmware); // Save firmware version
connected = true;
QObject::connect(serial, SIGNAL(readyRead()), this, SLOT(processReadyRead())); // Incomming "packets" are now handled by processReadyRead slot
return true;
}
//If it's not a wheel
serial->close();
}
return false;
}
示例5: parseStatus
void Git::parseStatus() {
QByteArray all = readStandardOutput();
QList<QByteArray> items = all.split('\0');
items.pop_back(); // remove last empty item
LockHolder<GitFileList> list = fileList.getLock();
list->clear();
for (const QString &item : items) {
// https://www.kernel.org/pub/software/scm/git/docs/git-status.html
GitFile::state fileState;
if (item.startsWith("??")) {
fileState = GitFile::state::CREATED;
} else if (item.startsWith(" M")) {
fileState = GitFile::state::MODIFIED;
} else if (item.startsWith(" D")) {
fileState = GitFile::state::REMOVED;
} else {
fileState = GitFile::state::UNKNOWN;
}
QString filename = item.mid(3);
list->append(GitFile{filename, fileState});
}
qDebug() << "emitim status\n";
onStatusUpdated();
}
示例6: TreeHuffmanTreeLeft
QString huffdecotification::TreeHuffmanTreeLeft(QString huff)
{
QString leftTree;
QList<char> verification;
if(huff.at(0).toLatin1()=='*' && huff.at(1).toLatin1()=='*')
{
verification.push_back('*');
for(int i=1; i<huff.size();i++)
{
if(huff.at(i).toLatin1()=='*' && huff.at(i-1).toLatin1()!='!')
{
verification.push_back('*');
}
else
{
if(huff.at(i).toLatin1()!='!')
verification.pop_back();
}
leftTree.append(huff.at(i));
if(verification.isEmpty())
{
break;
}
}
}
else
{
leftTree=huff.at(1);
if(huff.at(1).toLatin1()=='!')
{
leftTree=huff.at(2);
}
}
return leftTree;
}
示例7: TreeHuffmanDecodificationLeft
QString huffdecoditication::TreeHuffmanDecodificationLeft(QString huff)
{
QList<char> test;
QString TreeHuffmanDecodificationLeft;
if(huff.at(0).toLatin1()=='(')
{
test.push_back('(');
for(int i=1;i<huff.size();i++)
{
if(huff.at(i).toLatin1()=='(' && huff.at(i-1).toLatin1()!='-')
{
test.push_back('(');
}
if(huff.at(i).toLatin1()==')' && huff.at(i-1).toLatin1()!='-')
{
test.pop_back();
}
if(test.isEmpty())
{
break;
}
TreeHuffmanDecodificationLeft.append(huff.at(i));
}
}
else
{
TreeHuffmanDecodificationLeft=huff.at(0);
if(huff.at(0).toLatin1()=='-')
{
TreeHuffmanDecodificationLeft=huff.at(1);
}
}
return TreeHuffmanDecodificationLeft;
}
示例8: addRecentColor
void QgsRecentColorScheme::addRecentColor( const QColor &color )
{
if ( !color.isValid() )
{
return;
}
//strip alpha from color
QColor opaqueColor = color;
opaqueColor.setAlpha( 255 );
QgsSettings settings;
QList< QVariant > recentColorVariants = settings.value( QStringLiteral( "colors/recent" ) ).toList();
//remove colors by name
for ( int colorIdx = recentColorVariants.length() - 1; colorIdx >= 0; --colorIdx )
{
if ( ( recentColorVariants.at( colorIdx ).value<QColor>() ).name() == opaqueColor.name() )
{
recentColorVariants.removeAt( colorIdx );
}
}
//add color
QVariant colorVariant = QVariant( opaqueColor );
recentColorVariants.prepend( colorVariant );
//trim to 20 colors
while ( recentColorVariants.count() > 20 )
{
recentColorVariants.pop_back();
}
settings.setValue( QStringLiteral( "colors/recent" ), recentColorVariants );
}
示例9: getItemsFromQuery
bool Catalog::getItemsFromQuery(InputList &inputData, QList<CatItem>& outResults,
int itemsDesired,
int* beginPos){
QString userKeys = inputData.getUserKeys();
QList<CatItem> partialList = parseRequest(inputData,itemsDesired, beginPos);
plugins.getLabels(&inputData);
plugins.getResults(&inputData, &partialList);
//outResults = expandStubs(inputData.getUserKeys(), &partialList);
outResults = partialList;
//Skipping because it should happen in more detail later...
//...
//Sort by single keys ... even if we're on multiple words otherwise
if(inputData.selectingByKeys()){
Catalog::curFilterStr = userKeys;
qSort(outResults.begin(), outResults.end(), CatLessNoPtr);
while(outResults.count() > itemsDesired ){
outResults.pop_back();
}
}
return true;
}
示例10: if
bool ConnectionManager2::applyConfig(QVariant const & config)
{
if (config.type() != QVariant::List)
return false;
QList<Connection *> newConns;
struct cleanup
{
QList<Connection *> & conns;
cleanup(QList<Connection *> & conns) : conns(conns) {}
~cleanup() { for (int i = 0; i < conns.size(); ++i) conns[i]->releaseAll(); }
} cleanupGuard(newConns);
QList<QVariant> const & connConfigs = config.toList();
for (int i = 0; i < connConfigs.size(); ++i)
{
if (connConfigs[i].type() != QVariant::Hash)
return false;
QHash<QString, QVariant> const & connConfig = connConfigs[i].toHash();
QVariant typev = connConfig.value("type");
if (typev.type() != QVariant::String)
return false;
QString const & type = typev.toString();
ConnectionPointer<Connection> conn;
if (type == "serial_port")
conn.reset(new SerialPort());
else if (type == "tcp_client")
conn.reset(new TcpSocket());
else if (type == "udp_socket")
conn.reset(new UdpSocket());
#ifdef HAVE_LIBYB
else if (type == "usb_yb_acm")
conn.reset(new UsbAcmConnection2(m_yb_runner));
#endif
if (!conn)
return false;
QVariant settings = connConfig.value("settings");
if (settings.type() != QVariant::Hash || !conn->applyConfig(settings.toHash()))
return false;
newConns.push_back(conn.data());
conn.take();
}
this->clearUserOwnedConns();
while (!newConns.empty())
{
this->addUserOwnedConn(newConns.back());
newConns.pop_back();
}
return true;
}
示例11: cleanupEffectList
static void cleanupEffectList(QList<QGLColladaFxEffect*> &effects)
{
while (effects.count())
{
delete effects.back();
effects.pop_back();
}
}
示例12: deployDocument
/**
* @brief TreeModel::deployDocument this function is a recursive implementation of depth-first trasversal in a tree. With the depth-first iterator implemented later, we would be able to make this code shorter
* @param current the root we begin at
* @param parents une file des parents
* @param indent une file des indentation.
*/
void TreeModel::deployDocument(Document* current, QList<TreeItem*>& parents, QList<int>& indent){
TreeItem *parent = parents.last();
if(current!=nm->getRootDocument()){
// current as a child of its parent
indent.append(indent.last()+1);
parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
parent->child(parent->childCount() - 1)->setData(0, current->getTitle(), current);
}
// current becomes a new parent
TreeItem *tmp = parent->child(parent->childCount() - 1);
if(tmp)
parents << parent->child(parent->childCount() - 1);
else{
parents << rootItem;
}
for (nListIt it = current->begin(); it!=current->end(); ++it){
// qDebug()<<"Note Title: " << current->getTitle()<<" Filtered? :"<<filterKit->isFilteredByFilters(current);
// qDebug()<<"is ~ Document? " << (current!=nm->getRootDocument());
if((*it)->isDeleted() || (*it)!=rootItem->getItemId() && filterKit->isFilteredByFilters((*it))){
// We don't want to filter our root Document.
// We apply all enabled filters.
continue;
}
// If it is a doc, we deploy this doc.
if((*it)->isDocument()){
deployDocument(dynamic_cast<Document*>(*it), parents, indent);
}
else{
// We add it as a child.
QVector<QVariant> data;
data << (*it)->getTitle();
TreeItem *parent = parents.last();
parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
for (int column = 0; column < data.size(); ++column)
parent->child(parent->childCount() - 1)->setData(column, data[column], *it);
}
}
parents.pop_back();
indent.pop_back();
}
示例13: remove
void VideoWindow::remove(QList<int> rows){
disconnect(this->ui->sequence,SIGNAL(itemSelectionChanged()),this,SLOT(review()));
while(rows.size()>0){
this->eventsPositionInMiliseconds.removeAt(rows.last());
this->ui->sequence->removeRow(rows.last());
rows.pop_back();
}
connect(this->ui->sequence,SIGNAL(itemSelectionChanged()),this,SLOT(review()));
this->checkSaveCondition();
}
示例14: readString
void ConnectorOld::readString()
{
recvBuffer += readAll();
if (recvBuffer.split('\n').count() == 1) // Verify for not full message
return;
QList<QByteArray> recvStrings = recvBuffer.split('\n'); // Splitting messages
recvBuffer = recvStrings.last(); // Save not full on buffer
recvStrings.pop_back(); // Remove not full from list
QList<QByteArray>::const_iterator it;
for (it = recvStrings.constBegin(); it != recvStrings.constEnd(); ++it)
emit readStringReady(*it);
}
示例15: end
void tst_QList::end() const
{
QList<QString> list;
list << "foo" << "bar";
QCOMPARE(*--list.end(), QLatin1String("bar"));
// remove an item, make sure it still works
list.pop_back();
QVERIFY(list.size() == 1);
QCOMPARE(*--list.end(), QLatin1String("foo"));
}