本文整理汇总了C++中QQueue::pop_front方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::pop_front方法的具体用法?C++ QQueue::pop_front怎么用?C++ QQueue::pop_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::pop_front方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMusics
void MusicPage::addMusics(int listId, QQueue<MusicInfo> musics)
{
MusicInfo musicInfo;
MusicList *musicList;
int row;
while (!musics.empty())
{
musicInfo = musics.front();
musics.pop_front();
musicList = (MusicList *)musicLists->widget(listId);
row = musicList->count();
QListWidgetItem *item = new QListWidgetItem(musicList);
item->setSizeHint(QSize(item->sizeHint().width(), 30));
musicList->insertItem(row, item);
MusicListItem *itemwidget = new MusicListItem(musicList);
itemwidget->setName(musicInfo.getName());
itemwidget->setArtist(musicInfo.getArtist());
musicList->setItemWidget(item, itemwidget);
/*
musicList->insertRow(row);
QTableWidgetItem *nameItem = new QTableWidgetItem(musicInfo.getName());
QTableWidgetItem *artiseItem = new QTableWidgetItem(musicInfo.getArtist());
nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
artiseItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
musicList->setItem(row, 0, nameItem);
musicList->setItem(row, 1, artiseItem);
musicList->setCurrentCell(row, 0);
*/
}
}
示例2: initializeAnimation
void BFS::initializeAnimation(){
setMenu(false);
int r=255, g=255, b=0;
int color_step= 25;
m_operations.push_back([=,this](){ getNode(_currentNode)->setColor(QColor(r, g, b));colorNode(_currentNode); });
r-=color_step;
g-=color_step;
QQueue<int> queue;
queue.append(_currentNode);
getNode(_currentNode)->setVisited(true);
while(!queue.empty()){
int curr = queue.at(0);
queue.pop_front();
NodeList list = getNeighbours(curr);
for (auto iter : list){
if(!getNode(iter)->visited()){
getNode(iter)->setVisited(true);
m_operations.push_back([=,this](){getEdge(curr, iter)->setColor(QColor(r,g,b)); colorEdge(curr, iter); emit highlightLine(10);});
m_operations.push_back([=,this](){getNode(iter)->setColor(QColor(r,g,b)); colorNode(iter);});
queue.append(iter);
}
}
r-=color_step;
g-=color_step;
}
m_animationInitialized= true;
m_currentStepInAnimation= 0;
m_numberOfStepsInAnimation= m_operations.size();
}
示例3: bfs
// Returns true if there is a path from source 's'
// to sink 't' in residual graph.
int Graph::bfs(int s, int t) {
visited_.fill(false);
QQueue<int> q;
q << s;
parent_[s] = -1;
visited_[s] = true;
while (!q.empty()) {
int u = q.front();
q.pop_front();
for (auto& v : r_edges_[u].keys()) {
if (!visited_[v] && qAbs(r_edges_[u][v])>Float::epsilon()) {
q << v;
parent_[v] = u;
visited_[v] = true;
if (v == t) q.clear();
}
}
}
// if we reached sink in BFS starting from source, then return true, else false
return (visited_[t] == true);
}
示例4: getFramebuffer
gpu::FramebufferPointer FramebufferCache::getFramebuffer() {
if (_cachedFramebuffers.isEmpty()) {
_cachedFramebuffers.push_back(gpu::FramebufferPointer(gpu::Framebuffer::create(gpu::Element::COLOR_RGBA_32, _frameBufferSize.width(), _frameBufferSize.height())));
}
gpu::FramebufferPointer result = _cachedFramebuffers.front();
_cachedFramebuffers.pop_front();
return result;
}
示例5: addMusics
void MyPlayer::addMusics(QString name, QQueue<MusicInfo> q)
{
MusicInfo musicInfo;
while (!q.empty())
{
musicInfo = q.front();
q.pop_front();
list[name].push_back(QUrl::fromLocalFile(musicInfo.getDir()));
}
}
示例6: LevelOrder
void AVLTree::LevelOrder()
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
QQueue<TreeNode*> q;
q.push_back(root);
while (!q.empty())
{
TreeNode *node = q.front();
q.pop_front();
if (node == NULL) continue;
group->addAnimation(node->getPopAnim());
q.push_back(node->Lson);
q.push_back(node->Rson);
}
group->start(QAbstractAnimation::DeleteWhenStopped);
}
示例7: readData
void MusicWindow::readData()
{
if (!Data::connectData()) return;
this->setBackgroud(Data::getCurrentBackground());
this->bottomBar->setPlayMode(Data::getPlayMode());
this->bottomBar->setSoundLevel(Data::getSoundLevel());
QQueue <QString> qq = Data::getListList();
QString listName;
QQueue <MusicInfo> q;
while (!qq.empty())
{
listName = qq.front();
qq.pop_front();
musicPage->createList(listName);
q = Data::getMusicList(listName);
musicPage->addMusics(Data::getListId(listName), q);
player->addMusics(listName, q);
}
musicPage->setCurrentList(0);
}
示例8: addChildren
void DockWidget::addChildren(QObject *object)
{
if (!object->isWidgetType())
{
return;
}
QQueue<QObject*> install;
install.push_back(object);
while (!install.empty())
{
object = install.front();
install.pop_front();
object->installEventFilter(this);
for (auto &i : object->children())
{
if (i->isWidgetType())
{
install.push_back(i);
}
}
}
}
示例9: addMusicsToEnd
void Data::addMusicsToEnd(QString listName, QQueue<MusicInfo> musics)
{
QSqlDatabase::database().transaction();
listName = listName.replace("'", "''");
tryConnectMusicList();
int cnt;
QSqlQuery query;
QString str =
QString("select * from listlist where name='%1';").arg(listName);
query.exec(str);
if (query.next())
cnt = query.value(2).toInt();
else
cnt = 0;
MusicInfo musicInfo;
while (!musics.empty())
{
musicInfo = musics.front();
QString str
= QString("insert into "
"musiclist(listname, id, dir, name, artist) "
"values('%1', %2, '%3', '%4', '%5');").arg(
listName).arg(
cnt).arg(
musicInfo.getDir().replace("'", "''")).arg(
musicInfo.getName().replace("'", "''")).arg(
musicInfo.getArtist());
qDebug() << "Add music:" << musicInfo.getName() << endl;
query.exec(str);
cnt++;
musics.pop_front();
}
query.exec("select * from listlist;");
str = QString("update listlist set count = %1 "
"where name = '%2';").arg(cnt).arg(listName);
query.exec(str);
QSqlDatabase::database().commit();
}
示例10: isMovable
bool ChessModel::isMovable(char player, QPair<int, int> st, QPair<int, int> ed) const
{
if (player == 'A') {
st.first = 14 - st.first;
st.second = 6 - st.second;
ed.first = 14 - ed.first;
ed.second = 6 - ed.second;
}
if (st.first < 1 || st.first > 13 || st.second < 1 || st.second > 5 ||
ed.first < 1 || ed.first > 13 || ed.second < 1 || ed.second > 5) return 0;
if (getChessId(player, ed) != -1) return 0;
if (getChessId(player, st) == -1) return 0;
if (isHouse(ed) && (getChessId('A' + 'B' - player, ed) != -1)) return 0;
int pt = pieceType[getChessId(player, st)];
if (pt == 10 || pt == 12) return 0;
if (ed.first == 7 && (ed.second == 2 || ed.second == 4)) return 0;
if ((st.first == 1 || st.first == 13) && (st.second == 2 || st.second == 4)) return 0;
int dis = abs(st.first - ed.first) + abs(st.second - ed.second);
if (dis == 1) return 1;
if (dis == 2 && (isHouse(st) || isHouse(ed))) return 1;
if (isRail(st) && isRail(ed)) {
if (st.first == ed.first) {
bool flag = 1;
for (int i = qMin(st.second, ed.second) + 1; i <= qMax(st.second, ed.second) - 1; i++)
if (getChessId('A', qMakePair(st.first, i)) != -1 || getChessId('B', qMakePair(st.first, i)) != -1)
flag = 0;
if (flag) return 1;
}
if (st.second == ed.second) {
bool flag = 1;
for (int i = qMin(st.first, ed.first) + 1; i <= qMax(st.first, ed.first) - 1; i++)
if (getChessId('A', qMakePair(i, st.second)) != -1 || getChessId('B', qMakePair(i, st.second)) != -1)
flag = 0;
if (flag) return 1;
}
if (pt != 9) return 0;
QQueue< QPair<int, int> > queue;
QSet< QPair<int, int> > set;
queue.push_back(st);
while (!queue.empty()) {
QPair<int, int> now = queue.front();
queue.pop_front();
for (int i = 0; i < 4; i++) {
QPair<int, int> tmp = now;
tmp.first += dx[i];
tmp.second += dy[i];
if (isRail(tmp) && getChessId('A', tmp) == -1 && getChessId('B', tmp) == -1 && set.find(tmp) == set.end()) {
queue.push_back(tmp);
set.insert(tmp);
}
}
}
for (auto itm : set) {
if (qAbs(itm.first - ed.first) + qAbs(itm.second - ed.second) <= 1)
return 1;
}
}
return 0;
}