Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-91911

Qt combines values from unrelated enum types

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 6.0.0, 5.15
    • Core: Other
    • None

    Description

      Combining values from unrelated enumeration types raises static analyzer warnings, e.g. for code

      QPainter p(this);
      p.drawText(textRect, Qt::TextWordWrap|Qt::AlignVCenter, text); 

      Qt::TextWordWrap is a Qt::TextFlag, while Qt::AlignVCenter is a Qt::AlignmentFlag value. QPainter::drawText takes an int for the flags. QPen enums have related problems (Qt::PenStyle, Qt::PenCapStyle, and Qt::PenJoinStyle are designed so that they can be merged).

      While explicitly casting the values to (u)int pacifies the analyzer, we should perhaps implement operators that allow combining values from those particular enums type-safely.

      Attachments

        For Gerrit Dashboard: QTBUG-91911
        # Subject Branch Project Status CR V

        Activity

          People

            vhilshei Volker Hilsheimer
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes