Thanks Wysota. I have a function that updates a QString/varchar database field.
When that changes, I want to display the new value in the status bar as a permanent message preceded by some text. The text appears ok, but when I try code to pass the value, I can't get a compile. Just my lack of Qt knowledge, but I can't seem to find any references to doing this. Can't find anything in my books or online.
Here are some code snippets of what I tried:
{
Q_OBJECT
public:
void makeControlDB();
signals:
void valueChanged
(QString newValue
);
}
//cpp file
ControlDB
::ControlDB(QObject *parent
){
}
void ControlDB
::setOper(QString oper
) { //some code to change the oper value
emit valueChanged(oper);
}
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
setupActions();
statusBar()->addPermanentWidget(mStatLabel);
ControlDB ctrl;
connect(&ctrl,
SIGNAL(valueChanged
(QString)),
this,
SLOT(updateStats
(QString)));
}
void MainWindow::updateStats(oper)
{
QString operOutput
= "Current op is " + oper;
mStatLabel->setText(operOutput);
}
class ControlDB:public QObject
{
Q_OBJECT
public:
ControlDB(QObject *parent = 0);
void makeControlDB();
void setLastLog(QString);
void setOper(QString);
QString getLastLog();
QString getOper();
signals:
void valueChanged(QString newValue);
}
//cpp file
ControlDB::ControlDB(QObject *parent)
{
}
void ControlDB::setOper(QString oper) {
//some code to change the oper value
emit valueChanged(oper);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
setupActions();
mStatLabel = new QLabel;
statusBar()->addPermanentWidget(mStatLabel);
ControlDB ctrl;
connect(&ctrl, SIGNAL(valueChanged(QString)), this, SLOT(updateStats(QString)));
updateStats(QString);
}
void MainWindow::updateStats(oper)
{
QString operOutput = "Current op is " + oper;
mStatLabel->setText(operOutput);
}
To copy to clipboard, switch view to plain text mode
Thanks for any assistance.
Bookmarks