Project

General

Profile

Feature #1483

Qt5 drops (q_)foreach in a future release

Added by lucebac about 5 years ago. Updated 6 months ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
General / Unspecified
Target version:
Start date:
05/15/2018
Due date:
% Done:

0%

Estimated time:
OS:
Any

Description

Quassel makes use of q_foreach (or rather Qt's foreach macro) multiple times in it's code. According to a note in the Qt documentation, "the usage of this macro is discouraged" since Qt 5.7 (http://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH). The alternative to that is to use C++11's ranged-for loops (as also suggested in the documetation of Qt). Since Quassel requires C++11 for 0.13 onwards anyway, this does not break backwards compatibility to previous releases.

digitalcircuit suggested to handle this whilst doing the huge code cleanup planned for 0.13.

History

#1 Updated by digitalcircuit almost 2 years ago

  • Status changed from New to Confirmed

This appears to still be the case in 0.14rc1, marking this as confirmed for now. Pardon the long delay.

#2 Updated by Lynnbautista 6 months ago

Instead you can use the C++11 for(:):

for(int i:list) {
qDebug() << i;
}
Note that you will have to compile with the C++-11 flag, therefore add this line to your project file:

QMAKE_CXXFLAGS += -std=c++11
Note that the C++11 for is more efficient than the Qt foreach as indicated by: Qt foreach loop ordering vs. for loop for QList

Also available in: Atom PDF