Skip to content

COMP: Fix ambiguous QString::arg() overload for char arguments in Qt5#1375

Merged
jamesobutler merged 1 commit intocommontk:masterfrom
BRAINSia:pr/qstring-arg-overload
Mar 28, 2026
Merged

COMP: Fix ambiguous QString::arg() overload for char arguments in Qt5#1375
jamesobutler merged 1 commit intocommontk:masterfrom
BRAINSia:pr/qstring-arg-overload

Conversation

@hjmjohnson
Copy link
Copy Markdown
Contributor

@hjmjohnson hjmjohnson commented Mar 24, 2026

Cherry-picked from #1372, part of a systematic clazy static analysis effort to improve CTK for Slicer compatibility and Qt6 migration.

What this changes

Wraps char literal arguments to QString::arg() in QChar() to resolve the ambiguous overload introduced in Qt5. Without this fix, the compiler selects the wrong overload, which can produce incorrect output and triggers a compiler warning.

Affected file: Libs/Widgets/ctkFontButton.cpp

Why

Compiler warning and potential wrong-overload selection in Qt5+. QString::arg(char) is ambiguous between arg(QChar) and arg(int) — wrapping in QChar() makes the intent unambiguous.

Testing

  • Builds cleanly with zero new compiler warnings
  • Existing tests pass (no regressions)

🤖 Identified via clazy static analysis using CTK-claude-skills

@hjmjohnson hjmjohnson changed the title COMP COMP: Fix ambiguous QString::arg() overload for char arguments in Qt5 Mar 24, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review March 26, 2026 13:33
@hjmjohnson
Copy link
Copy Markdown
Contributor Author

@jcfr A small change for better Qt6 support.

Wrap char ternary expressions with QChar() to disambiguate between
QString::arg(QChar) and QString::arg(int) overloads that are ambiguous
in Qt5 when passed plain char values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jamesobutler jamesobutler force-pushed the pr/qstring-arg-overload branch from d6194b0 to 7d2d6af Compare March 28, 2026 15:34
@jamesobutler jamesobutler enabled auto-merge (rebase) March 28, 2026 15:34
@hjmjohnson
Copy link
Copy Markdown
Contributor Author

@jamesobutler Thank you. FYI: I do not have the privileges to merge or add reviewers.

@jamesobutler jamesobutler merged commit 9e55b12 into commontk:master Mar 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants