• 4291阅读
  • 4回复

X11下用QT designer编的程序怎么在非X11环境下使用 [复制链接]

上一主题 下一主题
离线leaver
 
只看楼主 倒序阅读 楼主  发表于: 2006-05-30
— 本帖被 XChinux 从 Qt for Windows 移动到本区(2010-02-08) —
请问X11下用QT designer编的程序怎么在非X11环境下使用?
我编的程序在图形界面下可以用但在文字界面下就提示“can not connect to X server”
请问诸位高手该怎么解决?
离线chwoozy

只看该作者 1楼 发表于: 2006-05-30
必须要进入X环境才能使用,因为Qt库只能运行在X库上的,不能在文字界面下运行
离线leaver
只看该作者 2楼 发表于: 2006-05-30
那可不可以修改使它在文字界面下调用其他的库?
离线jacklee
只看该作者 3楼 发表于: 2006-06-15
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();
  }
离线chwoozy

只看该作者 4楼 发表于: 2006-06-30
不好意思献丑了
快速回复
限100 字节
 
上一个 下一个