我在PyQt4中有一个小程序,我想将程序编译成Exe.我正在使用py2exe来做到这一点.我可以使用以下代码在Windows标题栏中成功设置图标,但是当我将其编译为exe时,图标会丢失,我会看到默认的Windows应用程序.这是我的计划:
import sys
from PyQt4 import QtGui
class Icon(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Icon')
self.setWindowIcon(QtGui.QIcon('c:/python26_/repy26/icons/iqor1.ico'))
app = QtGui.QApplication(sys.argv)
icon = Icon()
icon.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
****这是py2exe****的setup.py
from distutils.core import setup
import py2exe
setup(windows=[{"script":"iconqt.py"
,"icon_resources": [(1, "Iqor1.ico")]}]
,options={"py2exe":{"includes":["sip", "PyQt4.QtCore"]}})
Run Code Online (Sandbox Code Playgroud) 我正在学习C++并使用QT.我有一个小程序,我试图每秒更新PushButton的文本.标签是当前时间.我有一个计时器应该每秒超时,但似乎它永远不会.这是代码.
头文件
#ifndef _HELLOFORM_H
#define _HELLOFORM_H
#include "ui_HelloForm.h"
class HelloForm : public QDialog {
public:
HelloForm();
virtual ~HelloForm();
public slots:
void textChanged(const QString& text);
void updateCaption();
private:
Ui::HelloForm widget;
};
#endif /* _HELLOFORM_H */
Run Code Online (Sandbox Code Playgroud)
CPP文件
#include "HelloForm.h"
#include <QTimer>
#include <QtGui/QPushButton>
#include <QTime>
HelloForm::HelloForm(){
widget.setupUi(this);
widget.pushButton->setText(QTime::currentTime().toString());
widget.pushButton->setFont(QFont( "Times", 9, QFont::Bold ) );
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption()));
timer->start(1000);
connect(widget.pushButton, SIGNAL(clicked()), qApp, SLOT(quit()) );
connect(widget.nameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
}
HelloForm::~HelloForm() {
}
void HelloForm::textChanged(const QString& …Run Code Online (Sandbox Code Playgroud)