QT可以在字符界面下的
只要你编的就是CUI的程序,没有调用GUI的类
在QApplication里设参数就可以了
QApplication::QApplication ( int & argc, char ** argv, bool GUIenabled )
Constructs an application object with argc command line arguments in argv. If GUIenabled is true, a GUI application is constructed, otherwise a non-GUI (console) application is created.
Set GUIenabled to false for programs without a graphical user interface that should be able to run without a window system.
On X11, the window system is initialized if GUIenabled is true. If GUIenabled is false, the application does not connect to the X server. On Windows and Macintosh, currently the window system is always initialized, regardless of the value of GUIenabled. This may change in future versions of Qt.
The following example shows how to create an application that uses a graphical interface when available.
int main(int argc, char **argv)
{
#ifdef Q_WS_X11
bool useGUI = getenv("DISPLAY") != 0;
#else
bool useGUI = true;
#endif
QApplication app(argc, argv, useGUI);
if (useGUI) {
// start GUI version
...
} else {
// start non-GUI version
...
}
return app.exec();
}