Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Closing program with threads with the close bottom
Forum Updated to NodeBB v4.3 + New Features

Closing program with threads with the close bottom

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    browser90
    wrote on 29 Dec 2012, 14:42 last edited by
    #1

    Dear,

    I'm having a program that runs threads and when I close the app via the X button in the right corner then the program crashes because the threads keeps running.

    How can I program the red x for closing the program so that the program stops correct without errors?

    This is how I start my thread:

    @ QFuture<void> future = QtConcurrent::run(thread,&pars);@

    Kind regards,

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 31 Dec 2012, 03:02 last edited by
      #2

      Hello browser90,

      Have a look at the example under "QWidget::closeEvent()":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#closeEvent

      Unfortunately, you can't cancel a thread started by QtConcurrent::run(). You could hide() your window, wait for the thread to finish, then quit your program.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      1/2

      29 Dec 2012, 14:42

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved