Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Save sort and col on tableWigets event
I have an problem when I try to save the states od tableWidgets with SIGNAL.
this is my code (Qt 4.8.7) :
connect(ui->tableWidget->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder )), this, SLOT(on_tableWidgetCust_sort(int, Qt::SortOrder)) ); connect(ui->tableWidget->horizontalHeader(), SIGNAL(geometriesChanged()), this, SLOT(on_tableWidgetCust_geo()) );
when I run I have this message:
QMetaObject::connectSlotsByName: No matching signal for on_tableWidgetCust_sort(int,Qt::SortOrder) QMetaObject::connectSlotsByName: No matching signal for on_tableWidgetCust_geo()
Also, I have 4 tableWidgets to save in my widgets and some save and restore correctly but other not, order sort only and not width of colonne...s strange comportement.
How do you do to save and restore states of tableWidgets correctly with events ?
Maybe a silly question but do you have a on_tableWidgetCust_sort slot in your widget ?
@SGaist Unfortunately no... but I found the strange comportement :
Before restore the state, I used setColumnWidth function.
// Code forget to delete ui->tableWidget->setColumnWidth(2,300); // <- causes strange behavior with restoreState function // Restore state ui->tableWidget->horizontalHeader()->restoreState(m_settings->getTableCustomers());
After have deleted this line, It works well... but there is always warning message on slot...(in release version)
Then you have have to implement a slot named
on_tableWidgetCust_sortif you need it or delete the connection from designer.
cfdev last edited by cfdev
@SGaist yes I need both slots, one on geometric change and an other on sort change! I use savestate on this slots.
I dont use the designer tool to create this slots (not presents) and it's possible that the raison of this warning message.... Because I connect the signal to slot in construct widget.
Ok, then change the name of these slots by e.g. removing underscores use camel case onTableWidgetCustSort. Currently the name of your slots uses the same format as Designer to auto-connect signals from the widgets in your ui files to custom slots in your code.
@SGaist Ok!! it's just that thanks SGaist ;)