Code Monkey home page Code Monkey logo

qcoreapplication_quit_example's Introduction

QCoreApplication_quit_example

This is simple example How to exit after QCoreApplication::exec()

Run app and after 3 second QCoreApplication_quit_example will close automatically with message "good bye".

To exit from you infinite cycle QCoreApplication::exec() try this

QTimer::singleShot(1000, this, &rial::closeApp); //if you need process some code in closeApp()

or this

QTimer::singleShot(1000, QCoreApplication::instance(), SLOT(quit())); //if you need quit() only

Also you can use Ctrl+C to exit. If user send Ctrl+C signal QCoreApplication_quit_example will use non-Qt function SigInt_Handler(). It tested on Ubuntu.

QCoreApplication_quit_SIGINT_example

QCoreApplication_quit_SIGINT_example is more powerfull then QCoreApplication_quit_example. If user send Ctrl+C signal QCoreApplication_quit_SIGINT_example will use Qt non-static method rial::handleSignal(). In this method Qt start QTimer for 3 seconds and after do closeApp(). If user don't press Ctrl+C in console for QCoreApplication_quit_SIGINT_example this app will wating forever.

How run?

You can run this apps using Qt Creator. You can use external terminal if you need use this way

Qt Creator. Run proj in external terminal
Run proj in external terminal

You can send SIGINT by Ctr+C key. But also you can send SIGINT using Debug mode via GDB console. Before sending "signal 2" don't forget make Pause!

Qt Creator. Debug using gdb creator. Emit signal 2 via gdb console
SIGINT by GDB in Qt Creator

qcoreapplication_quit_example's People

Contributors

andreicherniaev avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.