Megaxela / QCodeEditor

Qt Code Editor widget.
MIT License
383 stars 118 forks source link

chore: use tabStopDistance instead of tabStopWidth #32

Closed ouuan closed 4 years ago

ouuan commented 4 years ago

See:

knarfS commented 4 years ago

Please check for Qt version (>=5.10) when using tabStopDistance, as I have to use Qt 5.7.1 for cross compiling.

ouuan commented 4 years ago

Please check for Qt version (>=5.10) when using tabStopDistance, as I have to use Qt 5.7.1 for cross compiling.

So should I close this for backwards compatibility?

ouuan commented 4 years ago

Or check Qt version then use different functions?

knarfS commented 4 years ago

Checking the Qt version and using tabStopDistance for version >= 5.10 and else using tabStopWidth should be fine. This way QCodeEditor will use the new property if available but remains backward compatible.

Something like:

#if QT_VERSION >= 0x050A00
    const int defaultIndent = tabStopDistance() / fontMetrics().averageCharWidth();
#else
    const int defaultIndent = tabStopWidth() / fontMetrics().averageCharWidth();
#endif