Die Definition von foreach
in Qt an folgende löst: so
# define Q_FOREACH(variable, container) \
for (QForeachContainer<QT_FOREACH_DECLTYPE(container)> _container_((container)); \
_container_.control && _container_.i != _container_.e; \
++_container_.i, _container_.control ^= 1) \
for (variable = *_container_.i; _container_.control; _container_.control = 0)
wie Sie for
Schleifen sind zwei sehen können gibt es möglicherweise Schlüsselwort die weiterhin nicht mit dem man nicht mehr weiter Sie möchten , aber der innere.
bearbeiten nach Kommentar des @ chi
Es gibt eine schöne Erklärung ist in der Qt-Header-Datei:
// Explanation of the control word:
// - it's initialized to 1
// - that means both the inner and outer loops start
// - if there were no breaks, at the end of the inner loop, it's set to 0, which
// causes it to exit (the inner loop is run exactly once)
// - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
// the outer loop to continue executing
// - if there was a break inside the inner loop, it will exit with control still
// set to 1; in that case, the outer loop will invert it to 0 and will exit too
, wie Sie es sehen können, nur der Pause keine Erwähnung der continue
ist. Und es gibt keine Erwähnung der continue
auf der foreach
Dokumentation Seite entweder: http://doc.qt.io/qt-4.8/containers.html#the-foreach-keyword nur die Pause wird vorgestellt. Wenn Sie
Wow. Die dem '_container_.control' zugrunde liegende Logik ist ... interessant. – chi
Egal was passiert, ein 'continue' oder ein' break' wird den aktuellen Block verlassen, so dass das ursprüngliche Problem nicht behoben wird. Es wird nicht zu "s.beginGroup" gehen! –
"Weiter" und "Pause" funktionieren in 'Q_FOREACH' gut. Vielleicht sind sie in der Gräuel gebrochen, die die Umsetzung ist, die auf VC6 funktioniert, aber dann ist alles andere bereits dort kaputt, also lasst uns nicht weiter darüber sprechen. –