Tag Archives: qt

Configure QT designer in pychar

Then configure Qt Designer in Pycharm
1. First install Qt and Qt Dsigner PIP Install PyQt5 PIP install PyqT5-Tools

5 in pycharm is D:\anaconda3\Library\bin\designer. Exe means the path to install designer.
do not know their own installation path:
win+s
enter designer, right click display path can

and then configure:

3 D:\anaconda3\Scripts\pyuic5 exe the same for their own installation program path
4 for:

F

i

l

e

N

a

m

e

FileName

FileName-o

F

i

l

e

N

a

m

e

W

i

t

h

o

u

t

E

x

t

e

n

s

i

o

n

FileNameWithoutExtension

FileNameWithoutExtension. Py
click ok below.


Package python3.1 + PyQt4 into exe

There are many programs that package Python as an exe, such as Py2exe, PyInstaller, and so on, but so far none of them support Python 3.1 well, so I’ll introduce CX_freeze 4.2.2 here, which also supports cross-platform running on Windows and Linux.
Cx_freeze download site is http://sourceforge.net/projects/cx-freeze/files/, want to undertake choosing according to install python version. For example, I am using python3.1, so I will download the file cx_Freeze- 4.2.2.2.win32-py3.1.msi. After running the installation package, the program is copied to the Python directory. There are two main places, one is C:/Python31/Scripts and the other is C:/Python31/Lib/site-packages/cx_Freeze
 
In previous versions of cx_Freeze, py was converted to exe through the script Freezepython.py, but in 4.2.2 Freezepython.py is gone and the main work is done by the C:/Python 31/scripts cxfree.bat.
There are two main ways to complete python exe packaging using cx_Freeze:
First, run cxfreeze. Bat directly through:
Go to the CMD command line, enter the C:/Python 31/scripts directory, and run cxfreed.bat-h to see its instructions. We can do an experiment with CX_freeze’s own sample.
Go to C :/ Python 31/scripts/ and run
cxfreeze C:/Python31/Lib/site-packages/cx_Freeze/samples/PyQt4/PyQt4app.py –install-dir=d:/123
Pytqt4app.py is packaged as exe, and the libraries it USES are also evaluated in the d:/123 directory.
 
Second, run setup.py:
In the example provided with CXfreeze C:/ python31/lib /site-packages/cx_Freeze/samples/PyQt4, there is a setup.py file. Open this file and we find that it is:

By running this script, packaging can be done automatically:
For example, if you go into C:/ python31/lib /site-packages/cx_Freeze/samples/PyQt4,
run
setup.py build
After that, a build/exe.win32-3.1 directory will appear under this directory, where you can see the packaged exe file. We want to package our script, copy this setup.py over, and put it in
executables = [Executable(“PyQt4app.py”, base = base)])
Change pyqt4app.py to your own script name.
 
Problems during packaging:
For Chinese support, if there is Chinese in the script and the encoding format is not specified, the packaging process will occur: UnicodeDecodeError: ‘utf8’ codec can ‘t decode bytes in the position of 1602: invalid data this kind of mistake, this blog post on http://www.cnblogs.com/xinzaitian/archive/2010/12/10/1902481.html, the author mentioned Chinese must be deleted.
In fact, Chinese characters can be retained by adding the following at the beginning of the script file:
#! /usr/bin/env python
#coding=utf-8
It is ok
 
Another problem is that if the packaged EXE file is run under “desktop” or other Chinese path, a window will pop up showing “Cannot get zipimporter” instance. So far, no good solution has been found

error MSB6006: cmd.exe “exited with code 3

Using VS2012 and QT5.5.1, the following error occurred when compiling the example:
C: \ Program Files \ MSBuild \ Microsoft (x86) Cpp \ v4.0 \ V110 \ Microsoft CppCommon. The targets (172, 5) : error MSB6006: “CMD. Exe” have quit, code is 3.
The picture is as follows:

The solution is as follows:

Right-click on the project and select Convert Project to Qt Add-in Project.

[Qt] error: call to non-static member function without an object argument


error: calls a non-static member function with no object arguments.
this error occurs because the class is not instantiated with .
Take a chestnut, for example:

 class Student
 {
 public:
 int getAge();
 };

The reason for this error may be that when you call the function getAge(), you are doing this:

 Student::getAge();

Or do it this way:

  Student.getAge();

This means that the member function is called without instantiating the class Student.
Fix one: Instantiate an object first

 Student XiaoWang;
 int age = XiaoWang.getAge();

Correction 2: Declare member functions as static functions

 class Student
 {
 public:
static  int getAge(); 
 };
 
 Student::getAge();

Take chestnuts, for example:


  QDir::mkpath(Path);

Error: Calling a non-static member function with no object arguments.
the reasons for this error is that the class does not instantiate and call mkpath function need to first class instantiation,
to:

   QDir tempDir;   
    tempDir.mkpath(Path); 

That’s right.
If you write your own class, you can also add the static keyword before the function’s declaration in the class body to declare the function as a static member and call it without instantiation.
such as:


QMessageBox::warning(this,tr("Warning"),tr("No Exist"));

Static member functions can be called directly with “ class :: function name “.

QT running prompt failed to create OpenGL context for format qsurfaceformat (version 2.0, options qflags() solution)

running on other computers today the Qt program I wrote reported the following error:

Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redbuffersize-1, greenbuffersize-1, bluebuffersize-1, depthbuffersize-1 alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1,
).
This is most likely to cause by not having the necessary graphics drivers installed.
Install a driver providing OpenGL 2.0 or higher, or, if This is not possible, Make sure the ANGLE Open GL ES 2.0 emulation software (libEGL. DLL, Libglesv2.dll and d3dcompiler_*. DLL) are available in the application executable’s directory or in a location listed in PATH.

baidu once no result, mostly is what driver problem or Qt reinstall problem

/usr/include/boost/type_traits/detail/has_binary_operator.hp:50: Parse error at “BOOST_JOIN”

qt-ros:

/usr/include/boost/type_traits/ has_binary_operation.hp :50: Parse error at “BOOST_JOIN” error

temporary solution:

modify /usr/include/boost/type_traits/detail/ has_binary_operation.hpp file

namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {

..

}

to

#ifndef Q_MOC_RUN
namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {
#endif

#ifndef Q_MOC_RUN
}
#endif


QT — get hard disk margin

header file:

#include < windows.h>

implementation:

quint64 ImageSave::getDiskFreeSpace(QString _driver)
{
	LPCWSTR lpcwstrDriver = (LPCWSTR)_driver.utf16();
	ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;
	if (!GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes))
	{
		qDebug() << "ERROR: Call to GetDiskFreeSpaceEx() failed.";
		return 0;
	}
	return (quint64)liTotalFreeBytes.QuadPart/1024/1024/1024;//返回单位G
}


Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes

Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.

today with Qt development of android application present such a wrong
Failed to notify ProjectEvaluationListener. AfterEvaluate (), but primary configuration failure takes precedence.
Java lang. IllegalArgumentException: android.buildToolsVersion is missing!

at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:84)
at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:467)
at com.android.build.gradle.BasePlugin.access$0(BasePlugin.groovy)
at com.android.build.gradle.BasePlugin$_createTasks_closure9.doCall(BasePlugin.groovy:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.Closure.call(Closure.java:423)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:65)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:504)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:83)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)

FAILURE:构建失败,出现异常

  • Where:
    构建文件’ F:\Qt\Qt5.5.1\Examples\Qt-5.5\widgets\widgets\ Build – analogc锁android_for_armeabi_v7a_gcc_4_8_qt_5_5_1 – debug \android-build\ Build。什么地方出了问题:
    在评估根项目’ android-build ‘时出现了一个问题。

    无效的修订:24.0.0-preview

    运行-stacktrace选项以获取堆栈跟踪。
    运行-stacktrace选项以获取堆栈跟踪。使用-info或-debug选项运行以获得更多日志输出。
    构建失败

    总时间:6.283秒
    构建android包失败!
    -有关更多信息,请使用- verbose运行此命令。
    22:46:03:进程“F: \ Qt \ Qt5.5.1 \ 5.5 \ android_armv7 \ bin \ androiddeployqt。exe”退出,退出代14码。
    错误构建/部署项目analogclock (kit: Android for armeabi-v7a (GCC 4.8, Qt 5.5.1))
    执行步骤” Build Android APK ”