Hi!
I'm trying to implement a sort of error-counter in a toolbar. For this error-counter i use a QToolbutton with different icons depending on the state (red for error, green for ok). Addionaly I use a QSpinBox for counting the errors.
Until now, everything is fine.
What I want to implement is the resetting of the spinbox-value by clicking on the toolbutton.
With the following code, the program crashes when I hit the button.
{
ui->setupUi(this);
....
ui->mainToolBar->addAction(ui->actionLostReset);
lostSpinBox.setMaximum(10000);
ui->mainToolBar->addWidget(lostSpinBox);
lostSpinBox->setValue(0); // here it works
...
}
...
void MainWindow::on_actionLostReset_triggered()
{
if (ui->actionLostReset->isChecked())
{
lostSpinBox->setValue(10); // here it crashes
}
}
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::Main Window)
{
ui->setupUi(this);
....
ui->mainToolBar->addAction(ui->actionLostReset);
QSpinBox *lostSpinBox = new QSpinBox(ui->mainToolBar);
lostSpinBox.setMaximum(10000);
ui->mainToolBar->addWidget(lostSpinBox);
lostSpinBox->setValue(0); // here it works
...
}
...
void MainWindow::on_actionLostReset_triggered()
{
if (ui->actionLostReset->isChecked())
{
lostSpinBox->setValue(10); // here it crashes
}
}
To copy to clipboard, switch view to plain text mode
If I do the same command to a spinbox in a widget everything is fine.
How can this be?
I'm using Qt 4.8.4. and Qwt 6.1 on a WinXP SP3.
Thanx for your help and please excuse my bad english.
Bookmarks