Hi,
QWidget has the property windowModified, which can be used to indicate, if a widget has been changed. If the property is true, an asterisk * can be shown in the window title by adding the placeholder [*] to the window title. See qt docu:
doc.qt.io/qt-6/qwidget.html#windowModified-prop
However, if the QTitanRibbon is used, this mechanism does not work anymore. The window title always shows the full placeholder no matter what the value of windowModified is. Here is a small example that produces the issue.
Clicking the "Modify" button should show the asterisk in the window title, clicking "Save" should remove the asterisk. But this does not work, the placeholder [*] is always shown (see attached screenshot).
#include <QApplication>
#include <QGroupBox>
#include <QToolButton>
#include <QVBoxLayout>
#include <QtitanRibbon.h>
#include <QtnRibbonMainWindow.h>
class MainWindow : public RibbonMainWindow
{
Q_OBJECT
public:
MainWindow()
: RibbonMainWindow()
{
auto groupBox = new QGroupBox( "Buttons", this );
auto button1 = new QToolButton( this );
button1->setText( "Modify" );
connect( button1, &QToolButton::clicked, this, [ this ]() { setWindowModified( true ); } );
auto button2 = new QToolButton( this );
button2->setText( "Save" );
connect( button2, &QToolButton::clicked, this, [ this ]() { setWindowModified( false ); } );
QVBoxLayout* vLayout = new QVBoxLayout;
vLayout->addWidget( button1 );
vLayout->addWidget( button2 );
groupBox->setLayout( vLayout );
setCentralWidget( groupBox );
ribbonBar()->addPage( tr( "First Page" ) );
ribbonBar()->setFrameThemeEnabled( true );
setWindowTitle( tr( "TableView Test[*] - asd" ) );
setWindowModified( false );
}
};
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
MainWindow mw;
mw.resize( 640, 480 );
mw.show();
return app.exec();
}
#include "main.moc"
Removing the 2 lines
ribbonBar()->addPage( tr( "First Page" ) );
ribbonBar()->setFrameThemeEnabled( true );
makes the windowModified property work as expected.
This was tested with Qt 6.5.2 for QTitanRibbon 6.5 and 6.7 on Ubuntu 22.04 and Windows 10.
Is there an option in QTitanRibbon that has to be set, to make this work? Or is this a bug?