本文整理汇总了C++中QVector::takeLast方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::takeLast方法的具体用法?C++ QVector::takeLast怎么用?C++ QVector::takeLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::takeLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseDefinition
static QStringList parseDefinition(const QString &definition)
{
QStringList result;
QString word;
bool ignoreWord = false;
QVector<QChar> braceStack;
foreach (const QChar &c, definition) {
if (c == '[' || c == '<' || c == '(') {
braceStack.append(c);
ignoreWord = false;
} else if (c == ']' || c == '>' || c == ')') {
if (braceStack.isEmpty() || braceStack.takeLast() == '<')
ignoreWord = true;
}
if (c == ' ' || c == '[' || c == '<' || c == '('
|| c == ']' || c == '>' || c == ')') {
if (!ignoreWord && !word.isEmpty()) {
if (result.isEmpty() || Utils::allOf(word, [](const QChar &c) { return c.isUpper() || c == '_'; }))
result.append(word);
}
word.clear();
ignoreWord = false;
} else {
word.append(c);
}
}
return result;
}
示例2: fill_algorithm
void QCanvas::fill_algorithm(QPointF start, QColor color,QColor border, bool time_sleep)
{
QVector<QPointF> stack;
QImage im(pix->toImage());
im.setPixel(start.toPoint(),color.rgb());
stack.push_back(start);
while(!stack.isEmpty())
{
QPoint tmp_pix = stack.takeLast().toPoint();
im.setPixel(tmp_pix,color.rgb());
size_t tmp_x = tmp_pix.x();
tmp_pix.setX(tmp_x+1);
while(im.pixel(tmp_pix) != border.rgb())
{
im.setPixel(tmp_pix,color.rgb());
tmp_pix.setX(tmp_pix.x()+1);
}
size_t x_r = tmp_pix.x() - 1;
tmp_pix.setX(tmp_x-1);
while(im.pixel(tmp_pix) != border.rgb())
{
im.setPixel(tmp_pix,color.rgb());
tmp_pix.setX(tmp_pix.x()-1);
}
size_t x_l = tmp_pix.x() + 1;
tmp_pix.setX(x_l);
tmp_pix.setY(tmp_pix.y()+1);
while(tmp_pix.x() <= x_r)
{
bool flag = false;
while(im.pixel(tmp_pix) != border.rgb() &&
im.pixel(tmp_pix) != color.rgb() &&
tmp_pix.x() <= x_r)
{
if(!flag)
flag = true;
tmp_pix.setX(tmp_pix.x()+1);
}
if(flag)
{
if (tmp_pix.x() == x_r &&
im.pixel(tmp_pix) != border.rgb() &&
im.pixel(tmp_pix) != color.rgb())
stack.push_back(tmp_pix);
else
stack.push_back(QPointF(tmp_pix.x()-1,tmp_pix.y()));
flag = false;
}
size_t x_st = tmp_pix.x();
while(im.pixel(tmp_pix) == border.rgb() ||
im.pixel(tmp_pix) == color.rgb() &&
tmp_pix.x() <= x_r)
tmp_pix.setX(tmp_pix.x()+1);
if(tmp_pix.x() == x_st)
tmp_pix.setX(tmp_pix.x()+1);
}
if(time_sleep)
{
pix->convertFromImage(im);
this->setPixmap(*pix);
QTime dieTime= QTime::currentTime().addMSecs(10);
while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
tmp_pix.setX(x_l);
tmp_pix.setY(tmp_pix.y()-2);
while(tmp_pix.x() <= x_r)
{
bool flag = false;
while(im.pixel(tmp_pix) != border.rgb() &&
im.pixel(tmp_pix) != color.rgb() &&
tmp_pix.x() <= x_r)
{
if(!flag)
flag = true;
tmp_pix.setX(tmp_pix.x()+1);
}
if(flag)
{
if (tmp_pix.x() == x_r &&
im.pixel(tmp_pix) != border.rgb() &&
im.pixel(tmp_pix) != color.rgb())
stack.push_back(tmp_pix);
else
stack.push_back(QPointF(tmp_pix.x()-1,tmp_pix.y()));
flag = false;
}
size_t x_st = tmp_pix.x();
while(im.pixel(tmp_pix) == border.rgb() ||
im.pixel(tmp_pix) == color.rgb() &&
//.........这里部分代码省略.........