【发布时间】:2011-09-22 11:52:09
【问题描述】:
QApplication::QApplication ( int & argc, char ** argv )
初始化窗口系统并构造一个应用程序对象 在 argv 中使用 argc 命令行参数。
警告:argc 和 argv 引用的数据必须在 QApplication 对象的整个生命周期。 另外,argc 必须是 大于零且 argv 必须包含至少一个有效字符 字符串。
来自此链接:http://doc.qt.io/qt-4.8/qapplication.html#QApplication
可执行文件的参数是什么?有什么例子吗?
我尝试指定如下内容:
anisha@linux-dopx:~/Desktop/notes/qt> make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../qtsdk-2010.05/qt/mkspecs/linux-g++-64 -I. -I../../../qtsdk-2010.05/qt/include/QtCore -I../../../qtsdk-2010.05/qt/include/QtGui -I../../../qtsdk-2010.05/qt/include -I. -I. -o widgets.o widgets.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/anisha/qtsdk-2010.05/qt/lib -o qt widgets.o -L/home/anisha/qtsdk-2010.05/qt/lib -lQtGui -L/home/anisha/qtsdk-2010.05/qt/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
anisha@linux-dopx:~/Desktop/notes/qt> ./qt 2 f g
anisha@linux-dopx:~/Desktop/notes/qt>
没有特别发生,我也不知道自己在做什么或应该做什么。
编辑1:我尝试./qt -style=windows的代码。
#include <QtGui>
int main (int argc, char *argv[])
{
QApplication app (argc, argv);
QWidget objQWidget;
objQWidget.show ();
objQWidget.resize (320, 240);
objQWidget.setWindowTitle ("Text to be shown on the title bar\n");
// Adding a "child" widget.
QPushButton *objQPushButton = new QPushButton ("Text to be shown on the button", &objQWidget);
objQPushButton->move (100, 100);
objQPushButton->show ();
return app.exec ();
}
【问题讨论】: