简体   繁体   中英

Adding Qt to existing GNU C++ program

I have a current C++ program built using GNU make. It is reasonably large - about a dozen .cpp files and a similar number of headers.

It all runs off the command line and currently just outputs to cout and cerr.

I want to add Qt interface elements to it - what is the best way to do this?

(I have built some Qt stuff in the past (not for a few years) though I am rusty - the C++ code I have now works and I don't want to change that, just fix the way it outputs information to the end user.)

You didn't specify whether you're interested in Qt Widgets or Qt Quick, so I'll assume widgets.

Fire up Qt Creator , and create a new Qt Widgets project . Open designer mode by double clicking on the .ui file that was created and start creating the interface that you want. If you just want somewhere to start integrating your logic, dump your existing code into mainwindow.cpp (or whatever you called it) and refactor it as you learn more about Qt.

For example, one of your buttons might cause a slot to be invoked, and you could then do all of your stuff in that slot.

There are also a lot of non-gui-related utility classes like QCommandLineParser that may help you out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM