This is very ismple. You would use Qt signal slot mechanism for this. You need to connect the button's clicked signal to your update handler slot for the database.
#include <QObject>
#include <QPushButton>
...
class UpdateHandler : public QObject
{
Q_OBJECT
public:
explicit UpdateHandler(QObject *parent) : QObject(parent)
{
connect(&m_pushButton, SIGNAL(clicked(bool)), SLOT(updateDatabase()));
}
public slots:
void updateDatabase()
{
// update the database here.
}
private:
QPushButton m_pushButton;
};
With C++11 support, this would be even simpler as you could use lambda.
UpdateHandler::UpdateHandler(QObject *parent) : QObject(parent)
{
connect(&m_pushButton , &QPushButton::clicked, [&] {
// update the database here
}};
}
Disclaimer: this is just proto type code, so this was not even compilation-tested, but it should get you going, I think.
Here is a good example how to create signals and slots using QtCreator:
Creating a Qt Widget Based Application
Here you can find the all Qt 4.8 documentation for that if you still happen to use that: