- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
QApplication::QApplication ( int & argc, char ** argv )
Initializes the window system and constructs an application object with argc command line arguments in argv.
Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.
来自此链接: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 ();
}
最佳答案
构造函数中传递的参数稍后可以通过静态方法访问QStringList QCoreApplication::arguments()
。这样,您的代码中的任何地方都可以处理命令行参数。
关于qt - 将 QApplication 与命令行参数一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7514299/
我想念任何Qt如果我替换 QApplication::exec() 的功能使用标准的 Windows 消息循环实现?这应该澄清我的意思: 运行事件处理的常用“Qt”方式: int main(int a
何时在 Windows 上调用虚函数 QApplication::saveState 和 QApplication::commitData?它们是否被调用,或者 session 管理只是 UNIX 的
有两个qApplications A & B,它们可以在各自的主窗口中分别执行。 我想实现以下目标: 1) //Open Application B. //Inside App B's code
我正在尝试运行一个简单的 hello world 示例,并且已经需要一些时间来弄清楚要使用的内容现在我验证了包含路径,QApplication 实际上应该在那里,但它抛出了上述错误。为了清楚起见,我的
当我首先运行 python-pyside2 项目服务器时,它运行良好。 而且该站点也运行良好,但是如果我按 F5 btn 在浏览器中刷新。 站点显示错误页面 Runtime at/ import sy
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我正在将 Qt 桌面应用程序移植到 Linux(Ubuntu 19.10、64 位桌面、Qt 5.12.5、gcc 版本 9.2.1),并且在 QApplication 完成后发现一些意外的线程仍然处
这里引用 Qt 文档: For any GUI application using Qt, there is precisely one QApplication object 很明显。但我不知道为什
这里引用 Qt 文档: For any GUI application using Qt, there is precisely one QApplication object 很明显。但我不知道为什
我正在尝试将修改后的 qt 程序作为库运行。我需要它而不是阻止主执行。 所以我想做的是运行 QApplication 并开始执行主应用程序。我该如何实现? 我的第一个想法是在一个单独的线程中运行它。
我需要在单击按钮时重新启动我的应用程序,但我遇到了一些问题。我尝试了两种方法: 已尝试 this suggestion它确实重新启动了应用程序,但是我得到了每个小部件的 Gtk_IS_INVISIBL
我试图在不同的线程中创建 QApplication,但发现了 2 个主要问题: 1- 我无法与 GUI 交互 2- 一些警告: 警告:QApplication 不是在 main() 线程中创建的。 Q
是否可以在退出前一个实例后创建和使用新的 QApplication 实例? 最佳答案 是的,您可以在销毁前一个实例后创建一个新的 QApplication。我在 Windows 中使用 PyQt4 验
我是 PyQt4(和 QT)的新手,我遇到了一个问题, 我已经对 QApplication 进行了子类化(以具有对应用程序真正全局的全局数据和函数): class App(QApplication):
我正在 3Dsmax 2015 上做一些简单的 PySide。 这是我的错误: python.ExecuteFile "C:\Program Files\Autodesk\3ds Max 2015\s
我有一个带有单个对话框窗口的 Qt 应用程序。主要看起来像这样: QApplication a(argc, argv); MyObject * myMobject = new QObject(&a);
我有一个带有通知区域图标的应用程序,因此主窗口可能会忽略关闭事件。我正在尝试在应用程序退出时保存首选项和历史记录。我还想在应用程序运行时处理注销。虽然该应用程序是跨平台的,但它在 GNU/Linux
QApplication::QApplication ( int & argc, char ** argv ) Initializes the window system and constructs
我应该在哪里使用 except 块来记录 QApplication 的异常? 这似乎不起作用: app = QtGui.QApplication(sys.argv) MainWindow = Main
在基本的 C++ Qt Widgets 应用程序中,在堆栈上创建一个 QApplication 或直接在 main 函数中对其进行堆分配是可行的,但是在堆上调用一个函数-分配一个 QApplicati
我是一名优秀的程序员,十分优秀!