Results 1 to 3 of 3

Thread: QToolbar: Trying to reset value of QSpinBox in QToolbar via QToolbutton results crash

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default QToolbar: Trying to reset value of QSpinBox in QToolbar via QToolbutton results crash

    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.
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::Main Window)
    2. {
    3. ui->setupUi(this);
    4. ....
    5. ui->mainToolBar->addAction(ui->actionLostReset);
    6. QSpinBox *lostSpinBox = new QSpinBox(ui->mainToolBar);
    7. lostSpinBox.setMaximum(10000);
    8. ui->mainToolBar->addWidget(lostSpinBox);
    9. lostSpinBox->setValue(0); // here it works
    10. ...
    11. }
    12. ...
    13. void MainWindow::on_actionLostReset_triggered()
    14. {
    15. if (ui->actionLostReset->isChecked())
    16. {
    17. lostSpinBox->setValue(10); // here it crashes
    18. }
    19. }
    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.
    Last edited by Janoschka; 9th October 2013 at 12:41.

Similar Threads

  1. Unable to add QToolButton to QToolbar on QWidget
    By rawfool in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2012, 10:52
  2. Hiding a QToolButton in a QToolBar
    By elcuco in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2009, 20:35
  3. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:11
  4. QToolBar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 19:48
  5. QToolBar help
    By Erlendhg in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2006, 15:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.