我真的很喜欢QML.我喜欢如何定义组件(与类相比)及其属性,并从其他地方(与对象相比)实例化它们.
我可以说,一个按钮,有一些外观和感觉,上面有标签文字.例如,可以使用此组件定义(Button.qml
)来完成此操作:
Item {
id: button
property string label
anchors.fill: parent
Rectangle {
anchors.fill: parent
radius: 10
color: "gray"
Text {
anchors.centerIn: parent
font.pixelSize: 20
text: button.label
color: "white"
}
}
}
Run Code Online (Sandbox Code Playgroud)
并在此主文件(main.qml
)中实例化:
Rectangle {
width: 300
height: 200
Button {
anchors.centerIn: parent
anchors.margins: 50
label: "Hello button!"
}
}
Run Code Online (Sandbox Code Playgroud)
但我看到以下限制:我只能定义一个带有一些属性的按钮模板,而不是一些占位符.实例中定义的所有子项都是直接子项,至少是默认值,我想更改此行为.
假设我想在按钮中放置一个项目(让我们说一个图像,但我不想告诉Button
它将是一个图像的定义).我想象这样的事情:
Item {
id: button
property Item contents <-- the client can set the placeholder content here
anchors.fill: parent …
Run Code Online (Sandbox Code Playgroud) 我在运行面部识别代码时面临一些属性错误.我的脸检测到代码运行完美.但是当我尝试运行面部识别代码时,它会显示一些属性错误.我用Google搜索并试图遵循所有步骤.但是,它仍然显示相同的错误.这是我的代码:
人脸识别
我收到以下错误:
C:\Users\MAN\AppData\Local\Programs\Python\Python36\python.exe C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognize1.py
Traceback (most recent call last):
File "C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognize1.py", line 4, in <module>
recognizer = cv2.createLBPHFaceRecognizer()
AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer'
Process finished with exit code 1.
Run Code Online (Sandbox Code Playgroud)
我正在使用Windows平台.python 3.6 version.Thanks提前.
这是我想用Alamofire将图像上传到服务器的代码,它不是错误但它无法将图像推送到服务器.我该怎么办 ?预先感谢.
let url = URL(string: urlString)!
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
let parameters = ["name": rname]
do {
urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: [])
} catch {
print(error)
}
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
let image = UIImage.init(named: "myImage")
let imgData = UIImageJPEGRepresentation(image!, 0.2)!
Alamofire.upload(multipartFormData: { MultipartFormData in
MultipartFormData.append(imgData, withName: "fileset", fileName: "name", mimeType: "image/jpg")
},with: urlRequest,encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
if let info = response.result.value …
Run Code Online (Sandbox Code Playgroud) 我想在配置文件中声明一个全局属性,并在其他文件中使用它.例如声明mainbg
:
Style.qml:
property color mainbg: 'red'
Run Code Online (Sandbox Code Playgroud)
并在其他QML文件(如view.qml
和main.qml
)中使用它.我该怎么做这个工作?
我想为我创建的每个对象创建一个唯一的ID - 这是类:
class resource_cl :
def __init__(self, Name, Position, Type, Active):
self.Name = Name
self.Position = Position
self.Type = Type
self.Active = Active
Run Code Online (Sandbox Code Playgroud)
我希望有一个self.ID,每次我创建一个新的类引用时自动递增,例如:
resources = []
resources.append(resource_cl('Sam Sneed', 'Programmer', 'full time', True))
Run Code Online (Sandbox Code Playgroud)
我知道我可以参考resource_cl,但我不确定如何从那里开始......
我是QT的新手.我知道你可以强制显示刷新,但我已经把我所有的头发拉出来试图找出方法.这是我特别想要做的.
我按下一个按钮(onClick信号事件),它运行代码,在显示器上更改图像(QLabel),等待输入,然后通过更改新图像(不同的QLabel)继续.我已经尝试了所有内容,直到onclick信号事件代码完成后,显示才会刷新.现在,我不是在等待用户输入,我正在使用usleep(~500 ms)进行测试.
从我读到的内容来看,QT是事件驱动的,这意味着我基本上创建了一堆事件,这些事件被置于一个空闲状态,并在(onClick信号事件)返回到(主循环)/(事件处理程序)时执行.我不想等到函数完成后,如果我必须完全根据事件完成这个例程,它将使编程非常痛苦.
如何强制QLabel像素图刷新.我已经尝试了一切.下面是我在onClick信号事件处理程序中尝试过的所有代码.(upButton是QLabel的名称,是pixmap)
update();
repaint();
ui->upButton->setUpdatesEnabled(TRUE);
update();
repaint();
QPaintEvent paintevent(ui->upButton->childrenRegion());
QPaintEvent * test = &paintevent;
paintEvent(test);
this->changeEvent(test);
ui->upButton->update();
ui->upButton->repaint();
ui->upButton->repaint(ui->upButton->childrenRegion());
repaint();
QApplication::sendPostedEvents();
this->parentWidget()->update();
usleep(100000);
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我现在只是在黑暗中拍摄.我试着查看示例代码并完成所有作业,但我迷路了.感谢任何帮助,建议和/或示例代码.
我想弄清楚如何在Qt中制作一条水平线.这很容易在Designer中创建,但我想以编程方式创建一个.我做了一些googleing并查看了ui文件中的xml但却无法解决任何问题.
这是ui文件中的xml:
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>150</x>
<y>110</y>
<width>118</width>
<height>3</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
Run Code Online (Sandbox Code Playgroud) 我为 android studio 创建了一个 webview 应用程序。但没有加载网址。错误是 net::ERR_ACCESS_DENIED。有人能帮忙吗
我正在尝试正常导入 TensorFlow python 包,但出现以下错误:
这是上面终端图像中的文本:
2020-02-23 19:01:06.163940: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-02-23 19:01:06.164019: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-02-23 19:01:06.164030: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
<module …
Run Code Online (Sandbox Code Playgroud) 我正在努力googletrans
,它运作得很好.从今天早上起,我开始低于错误.我经历了stackoverflow和其他网站的多个帖子,发现可能我的ip被禁止使用该服务一段时间.我尝试使用多个服务提供商互联网,有不同的IP和stil面临同样的问题?我也尝试googletrans
在不同的笔记本电脑上使用,仍然是同样的问题.. googletrans
包装破损或谷歌在他们的最后做了什么?
>>> from googletrans import Translator
>>> translator = Translator()
>>> translator.translate('?????.')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
translator.translate('?????.')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 172, in translate
data = self._translate(text, dest, src)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/client.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 180, in do
self._update()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/gtoken.py", line 59, in _update
code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
Run Code Online (Sandbox Code Playgroud)