Using Qtcreator 4.8.2 and Qt 5.12.1 in archlinux/ubuntu, I'm trying to connect a signal to a slot using traditional method of QObject::connect, but when I open bracket after SIGNAL or SLOT macro, code completion does not suggest me available signals or slots. I haven't seen such a problem since I have updated Qt to this latest version. What's the problem?
example of the code:
connect(serial, SIGNAL(readyRead()),this, SLOT(setEncValue()));
readyRead() and setEncValue() are not available in suggestion list, but not only these two slot and signal, there are actually no signals or slots shown in the suggestion list.
Related
Recently I upgraded from Qt 5.3.0 to Qt 5.3.1 and noticed that my TableView's which use a QSortFilterProxyModel as their model no longer update when I sort the proxy model.
You can see this in action by using the sample code here!
If you compile it with Qt 5.3.0 the table will sort but if you compile it with Qt 5.3.1 the model will sort (verified with qDebug statements) but the TableView will not update. This happens on both Windows and Linux.
To get around it I had to add emit layoutChanged() after I call this->sort().
My question is has anyone else noticed this and found out if this is by design or is a defect.
Thanks
I did a little more digging and I found a Qt bug filed for exactly this issue. QTBUG-40035 TableView, Sort doesn't work.
Turns out in Qt 5.3.1 another bug was resolved QTBUG-37983 which changed the QQMLDelegateModel to emit layoutChanged( QList, QAbstractItemModel::LayoutChangedHint) instead of simply emitting layoutChanged(). The TableView does not seem to be listening to the parameratized version of the layoutChanged() signal which is why I can fix this by manually emitting layoutChanged() after I call sort().
This apparently has been fixed by QTBUG-39492 in Qt 5.3.2
How might one blast QSound from a command line?
Under PyQt4, playSound.py could be as simple as this:
QtGui.QSound('start.wav').play()
Except it doesn't play without an .exec() style event dispatcher available.
So what's the simplest dispatch queue that doesn't pop a window up and quits on time?
QSound doesn't have a reliable and portable way to signal when the sound is done.
You could use phonon instead (code example in C++) and connect the MediaObject::finished() signal to the quit() slot of the application.
Why using PyQt for a CLI app? It seems overkill, you should embrace Python's batteries and use PyQt for the UI, that way is more portable if you need both CLI and GUI versions.
There are plenty of options for playing audio in plain Python. [1]
[1] http://wiki.python.org/moin/Audio/
Also check these here on SO:
Play audio with Python
Play a Sound with Python
The following standalone code works fine for me, without any windows popping up:
from PyQt4 import QtGui
s = QtGui.QSound('test.wav')
s.play()
while not s.isFinished():
sleep(0.1)
The s.isFinished() check is required because otherwise the script will immediately exit without having played the wav, because play() doesn't block.
http://doc.qt.io/qt-5/qsound.html
from PyQt4.QtGui import QSound
QSound.play("Filename")
Is there any way to achieve hot-plugging of USB mouse in DirectFB 1.2.9 or Qt Embedded 4.7.3?
Currently my application stack is thus..
-----------------
GUI
-----------------
Qt Embedded 4.7.3
-----------------
DirectFB 1.2.9
-----------------
/dev/input/eventX
-----------------
DirectFB opens the Linux input device node. Qt uses a QSocketNotifier to wait on the DirectFB event buffer and sets up a slot to read the mouse data. But on hot-plugging, DirectFB does not open the device node and no mouse events are generated.
As far as I understand so far, hot-plugging is not supported by DirectFb..
I tried disabling DirectFB's handling of the Linux input device (removing the dev node from linux-input-devices= option in directfbrc), and set QWS_MOUSE_PROTO="linuxinput:.." but this did not work for some reason. Seems no mouse events were generated. Even if I manage to get it to work, I don't think QT provides any support for hot-plugging either.
So is my only alternative to sub-class QMouseDriverPlugin and QWSMouseHandle classes?. For this, I am yet to figure out how to make QT use the sub-classes I implement. i.e, Once I implement these classes how do I link them into the QT input device handling frame-work, so that I can set something like QWS_MOUSE_PROTO="mylinuxinput:.."?
As far as I can remember, I encountered no issue with mouse or keyboard hotplugging in Qt Embedded 4.7.2 (without DirectFB). If you want to subclass yourself, modify the plugin starting from the linuxinput plugin. You'll find that in Qt sources: this is the directory where the plugins are placed, but some classes are included in other directories.
Also, are you getting data in your linux device after pluggin in? Did you try to cat the device?
I'm trying to create some kind of a server which allows me to start Qt's applications on remote machine via web browser.
I'm wondering it is possible to change/hide some symbols from Qt library (I thought about QApplication or QCoreApplication) without making any changes in code of application (I assume that it is already compiled and uses Qt shared library) and compiling my whole tailor-made Qt libs?
The reason why I need to do this is because I want to install my own specific EventFilter to QApplication and also be able to push my own created events to Qt application.
It also would be great if the solution could be used on all platforms :D
P.S. I know that it will not be possible I could subclass QApplication and modify all Qt apps to use my derived class but I would like to do this more craftily. ;-)
The tool GammaRay does all kinds of injecting code into Qt methods at runtime to attach and debug running Qt applications. You might want to have a look at its code base to see how it is done.
I can make native win32 calls (GetPixel/SetPixel) on a QWidget by using QWidget::getDC .. How do I do this for Mac builds?
Using QImage/QPixmap for retrieving pixel information is not an option because I need very fast access to what's already been drawn onto a QWidget via QPainter on both Windows and Mac.
The reason I am using GetPixel on windows is to implement 2d mouse picking.
I am not sure what you are trying to do but if you want the underlying window system handle/ID, you can use QWidget::winId() which returns HIViewRef or NSView on Mac depending on if it's Carbon or Cocoa version of Qt library.