Skip to content

Search highlight color settings do not persist after restart or in new windows (Qt 6.4+) #821

Description

@o3wiz

When changing the "Main/Quick find search highlight" background color in the Options menu, the color is correctly applied to the current window. However, when opening a new window restarting the application, the color reverts to the default gray.

The application correctly saves the chosen color to the configuration file, but fails to load it back into the session settings upon initialization.

mainSearchBackColor_
#if QT_VERSION <= QT_VERSION_CHECK( 6, 4, 0 )
.setNamedColor(
#else
.fromString(
#endif
settings
.value( "regexpType.mainBackColor",
DefaultConfiguration.mainSearchBackColor_.name( QColor::HexArgb ) )
.toString() );
qfBackColor_
#if QT_VERSION <= QT_VERSION_CHECK( 6, 4, 0 )
.setNamedColor(
#else
.fromString(
#endif
settings
.value( "regexpType.quickfindBackColor",
DefaultConfiguration.qfBackColor_.name( QColor::HexArgb ) )
.toString() );

For builds using Qt > 6.4.0,
the code calls QColor::fromString() as an instance method (e.g., mainSearchBackColor_.fromString(...)).
Because QColor::fromString is a static method in modern Qt, it returns a new QColor object and does not modify the existing one.
Since the returned value is not assigned back to the variable, the setting is effectively ignored.

This affects both mainSearchBackColor_ and qfBackColor_.

solution suggestion:
just replace .fromString(...) with = QColor::fromString(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions