Skip to content

Add bindings for QChar#1405

Open
jnbooth wants to merge 6 commits intoKDAB:mainfrom
jnbooth:qchar
Open

Add bindings for QChar#1405
jnbooth wants to merge 6 commits intoKDAB:mainfrom
jnbooth:qchar

Conversation

@jnbooth
Copy link
Contributor

@jnbooth jnbooth commented Feb 9, 2026

A QString is a list of QChars, but cxx-qt-lib doesn't currently have bindings for QChar. That means any time you want to interact with the QString as a list (split, add, remove, etc.), you need to allocate a new QString. This PR adds bindings for QChar so it can be used directly. That also makes it much easier to find out what's inside a QString without needing to convert it to a String.

A QChar is just a standard UTF-16 double byte, so there's no need for FFI calls. In fact, they can be constructed at compile time. That means instead of doing this:

fn split_items(s: &QString) -> QStringList {
    s.split(&QString::from("|"), /* other args */)
}

You can now do this:

const DELIM: QChar = QChar::from_char('|').unwrap();

fn split_items(s: &QString) -> QStringList {
    s.split(DELIM, /* other args */)
}

This is both more efficient (no allocations) and more readable (no "magic" strings).

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f41f139) to head (2332336).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1405   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           75        75           
  Lines        13124     13124           
=========================================
  Hits         13124     13124           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant