Ok,
with the mapper you can use the "int option". 1 = true and 0 = false.
//not tested but should work
sortListSignalMapper->setMapping(m_ui->sortAscendingButton, 1);
sortListSignalMapper->setMapping(m_ui->sortDescendingButton, 0);
connect(m_ui->sortAscendingButton, SIGNAL(clicked()), sortListSignalMapper, SLOT(map()));
connect(m_ui->sortDescendingButton, SIGNAL(clicked()), sortListSignalMapper, SLOT(map()));
connect(sortListSignalMapper, SIGNAL(mapped(int)), this, SLOT(sortStringList(bool)));
//not tested but should work
sortListSignalMapper = new QSignalMapper(this);
sortListSignalMapper->setMapping(m_ui->sortAscendingButton, 1);
sortListSignalMapper->setMapping(m_ui->sortDescendingButton, 0);
connect(m_ui->sortAscendingButton, SIGNAL(clicked()), sortListSignalMapper, SLOT(map()));
connect(m_ui->sortDescendingButton, SIGNAL(clicked()), sortListSignalMapper, SLOT(map()));
connect(sortListSignalMapper, SIGNAL(mapped(int)), this, SLOT(sortStringList(bool)));
To copy to clipboard, switch view to plain text mode
And with the button group you could simply use:
// use the buttonClicked(QAbstractButton *button) signal to connect to your slot
{
if(button == m_ui->sortAscendingButton)
listModel->sort(0, Qt::AscendingOrder);
else
listModel->sort(0, Qt::DescendingOrder);
}
// or if you need a bool function beside
{
return sortStringList(button == m_ui->sortAscendingButton);
}
// use the buttonClicked(QAbstractButton *button) signal to connect to your slot
void txtEdit::sortStringList(QAbstractButton *button)
{
if(button == m_ui->sortAscendingButton)
listModel->sort(0, Qt::AscendingOrder);
else
listModel->sort(0, Qt::DescendingOrder);
}
// or if you need a bool function beside
void txtEdit::sortStringList(QAbstractButton *button)
{
return sortStringList(button == m_ui->sortAscendingButton);
}
To copy to clipboard, switch view to plain text mode
Bookmarks