I have a console application using QCoreApplication in Qt5. This application has different functions like "printABC" or "printSUV". The output will appear in the terminal. Now I want to make a Gui, where I can push the buttons "printABC" or "printSUV" and the output will appear in the terminal too, so that it is 'easier' to use the application. In Qt5, I can make a console application using QCoreApplication, which I have already done. So my question is how can I add a QApplication which runs along the way? In the docs, it is recommended to create a QApplication/QCoreApplication in the main function, so how can I create both?
Related Questions in QT
- qt c++ fonction converting adress to coordinates (longitude, latitude)
- Qml table and chart using python
- Qt: running callback in the main thread from the worker thread
- i have installed qt version 6.0.3 and this error QMYSQL driver not loaded displaying again and again
- Frameless Qt + WinAPI maximized window size is bigger than the availableGeometry()
- new window with c++ qt
- How to get scaling from transformation matrix
- How to build just Qt core libraries from Qt sources
- doxyqml not documenting qml files properly
- Incorrect assignment from a QStringList to a char * array
- How to make QT Chart size larger than widget size?
- Queued async operations with QtConcurrent interfere QImage from freed
- Questions about qt5 dynamic link library
- how to document QML files inside C++ project?
- How do I keep my screen contents centered and also have a scrollbar in QT?
Related Questions in QAPPLICATION
- PySide6 runs code without issues but nothing appears
- Why does the application exit when closing a QMessageBox with an invisible parent window?
- Problem with displaying Charts in qml project: MUTEX problem
- QT5's QApplication::setOverrideCursor(Qt::WaitCursor); is blocking the previous operations
- AttributeError: module 'pyqtgraph.Qt.QtGui' has no attribute 'QApplication'."
- QApplication freeze sometimes, if i import QWebEngineView
- How to check filtered item in checkable ComboBox?
- python QApplication freezes and does not close while another thread is running
- Pushing QWidget Window to topmost in Python
- can't install katalon on ubuntu 22.04
- Cannot Close Spyder with PyQt5
- 'NoneType' error when calling QApplication(sys.argv), pycharm
- Qt , how to create QApplication without argc and argv
- QML menu style only works in QtWidgets QApplication
- I get "Release of profile requested but WebEnginePage still not deleted. Expect troubles !" even after calling app.exec()
Related Questions in QCOREAPPLICATION
- In a well-running multithreaded app, a defined callback will not be called. Why?
- Qt.5 Console Application pause and read console input
- list all signals emitted from qt application
- AttributeError: 'QCoreApplication' object has no attribute 'setQuitOnLastWindowClosed'
- QT5 error: Unknown type name 'QCoreApplication'. First program in Qt5
- When is QCoreApplication valid?
- How to detect if qt application exited normally or not?
- How to monitor QThread
- Can I use QApplication AND QCoreApplication?
- Can I use Qt network module without QCoreApplication?
- how to start event loop in shared library for Android?
- QEventLoop process all events
- QT QcoreApplication postEvent() behaviour
- Q_COREAPP_STARTUP_FUNCTION with static class member method
- Q_COREAPP_STARTUP_FUNCTION inside static library
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You can easily have a single application which supports both command-line (terminal) mode and GUI mode.
Just useQApplication(orQGuiApplicationfor QML-only app).UPDATE 1: The commenters are correct, it would be better to instantiate
QCoreApplicationorQ[Gui]Applicationdepending on which is actually needed...Then, for example, if a user passes CLI options, you just run the function(s) and send the result to
sdtout(presumably like you're doing now). Otherwise show the GUI and use the same functions but to display the data some other way (in the UI).UPDATE 2: ... So it would be better to parse the command line first and determine which Q*Application "flavor" should be used...
If you haven't yet, you can look into QCommandLineParser to help handle the CLI options. Just keep in mind that it works exactly the same with a
Q[Gui]Applicationas well.UPDATE 3: ... In fact
QCommandLineParsercan be used before aQ*Applicationis created. One just needs to callparse()with a list of options fromargv, instead ofprocess()with the app instance. See code example below.In
main(), handle any CLI options first. Then to NOT launch the GUI you could simplyexit(0)frommain()before callingapp.exec().A basic example:
If you want to show the output in the console from which the application was started, then you can still simply print to
stdout(or whatever you're doing now). However if you want this to work on Windows, additional steps may be required... and there are a few things to consider. This would really be the topic of a different question, I think. IMHO mixing the two (GUI in one window and output in console) could be rather awkward, and showing output in GUI makes it all nicely self-contained.