qtcore

No matching function for QObject::connect

大城市里の小女人 提交于 2020-05-26 11:12:16
问题 I'm writing a program that send an UDP frame every 10 mS. Here's how my program is supposed to work : I've got a client class : //Constructor clientSupervision::clientSupervision() { } void clientSupervision::sendDataUDP(){ //Create a frame and send it ... } void clientSupervision::sendDataUDPTimer(int timer){ QTimer *tempsEnvoieTrameSupervision = new QTimer();//Create a timer tempsEnvoieTrameSupervision->setInterval(timer);//Set the interval //Mise en place des connections QObject::connect

QMetaObject::invokeMethod doesn't find the method

青春壹個敷衍的年華 提交于 2020-01-24 23:10:35
问题 I want to use QMetaObject::invokeMethod to call a method of an object (later it will run in another thread and then invokeMethod comes in handy). I use the Qt 4.8 bindings of PySide 1.2.1 on Python 3.3. The full example is: from PySide import QtCore class Tester(QtCore.QObject): def __init__(self): super().__init__() def beep(self): print('beep') if __name__ == '__main__': t = Tester() QtCore.QMetaObject.invokeMethod(t, 'beep', QtCore.Qt.AutoConnection) And the output is: QMetaObject:

QString to char* conversion

烈酒焚心 提交于 2020-01-18 07:06:43
问题 I was trying to convert a QString to char* type by the following methods, but they don't seem to work. //QLineEdit *line=new QLineEdit();{just to describe what is line here} QString temp=line->text(); char *str=(char *)malloc(10); QByteArray ba=temp.toLatin1(); strcpy(str,ba.data()); Can you elaborate the possible flaw with this method, or give an alternative method? 回答1: Well, the Qt FAQ says: int main(int argc, char **argv) { QApplication app(argc, argv); QString str1 = "Test"; QByteArray

How to access a nested QML object from C++?

 ̄綄美尐妖づ 提交于 2020-01-12 06:54:28
问题 Here is a reproducible example: main.qml import QtQuick 2.0 Item { id : root width: 360 height: 360 Text { id : t1 text: qsTr("Hello World") property int someNumber: 1000 anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { Qt.quit(); } } } main.cpp #include <QtGui/QGuiApplication> #include <QQmlEngine> #include <QQmlComponent> #include <QQmlProperty> #include <QDebug> #include "qtquick2applicationviewer.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv)

QML Timer - How to improve accuracy?

亡梦爱人 提交于 2019-12-31 01:48:08
问题 I'm developing a QML metronome. I used a timer with interval 60000/Beats per minute. However it isn't really accurate. How can I improve the accuracy. Should I use a Timer, or is there a better solution? 回答1: The fundamental issue with QTimer that it uses the Qt event loop for the timing. Unfortunately, it cannot be accurate enough, inherently. The latency for notifications and all that within the event loop is getting in the way. You would need to consider a timer that does not actually

How to set Input Mask and QValidator to a QLineEdit at a time in Qt?

匆匆过客 提交于 2019-12-30 03:19:07
问题 I want a line edit which accepts an ip address. If I give input mask as: ui->lineEdit->setInputMask("000.000.000.000"); It is accepting values greater than 255. If I give a validator then we have to give a dot(.) after every three digits. What would the best way to handle it? 回答1: It is accepting value greater than 255. Absolutely, because '0' means this: ASCII digit permitted but not required. As you can see, this is not your cup of tea. There are at least the following ways to circumvent it

QByteArray to QString

大兔子大兔子 提交于 2019-12-30 00:15:24
问题 I'm having issues with QByteArray and QString . I'm reading a file and stores its information in a QByteArray . The file is in unicode, so it contains something like: t\0 e\0 s\0 t\0 \0 \0 I'm trying to compare this value to my specified value, but it fails, because in the debugger I see it's not an unicode string. The code will explain everything: QByteArray Data; //contains unicode string "t\0 e\0 s\0 t\0 \0 \0" QString myValue = "test"; //value to compare. if(Data.contains(myValue)) //do

Sending structured data over a network [closed]

▼魔方 西西 提交于 2019-12-24 07:36:29
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I'm a begginer in network programming, so, sorry if my questions may appear a little obvious. I'm trying to send some data from Qt application to a Python server which will process them and send back some answer. the methods that allows me to send data in the QTcpSocket class are:

PyQt: Dialog's Minimize Window Button is Missing in OSX

﹥>﹥吖頭↗ 提交于 2019-12-24 03:21:02
问题 A dialog created with: class GUI(QtGui.QMainWindow): def __init__(self): super(GUI, self).__init__() global dialog dialog = QtGui.QDialog() myGui = GUI() is missing a minimize window button (OSX). It is there in Windows. Do I have to set some flag to display this missing controller? Please advise, Thanks in advance! EDITED LATER: I didn't try to solve a no-minimize-button issue with QtGui.QDialog(). But it appears I partically aware how to get that missing button using QtGui.QMainWindow. Here

Qt application with optional gui

北战南征 提交于 2019-12-23 09:36:39
问题 I am going to write program using Qt for some image processing and I want it to be able to run in non-gui mode (daemon mode?). I'm inspired by VLC player, which is "typically" GUI program, where you can configure it using GUI, but you can also run it in non-gui option when it runs without GUI. Then it uses some configuration file created in GUI mode. Question is how should be such a program design? Should be some program core, which is GUI independent and depending on options it is being