Let's say you have your super duper Qt application ready for Android platform, but you want it to run on startup.
Monday, March 12, 2018
Thursday, February 8, 2018
Timer or Stopwatch?
A well known feature of Qt framework (at least what I guess) is the QTimer class, which essentially allows to have repetitive tasks or calculations at a given time interval. Think of it as a timer, that when it goes off, sends the timeout() signal and starts again the countdown for another interval. But a less known feature (at least what I guess) is the QElapsedTimer class, which acts the opposite: once started, you can know the elapsed time since that moment by calling the ellapsed() method.
Labels:
QEllapsedTimer,
Qt,
QTimer,
stopwatch,
timer
Thursday, January 18, 2018
Using Qt Creator to cross-compile and debug Raspberry Pi Qt5 apps
Have you ever wonder how to setup Qt Creator in your powerful workstation to develop Qt apps that can be deployed and tested in your Raspberry Pi (reachable from such workstation)?
Labels:
cross-compile,
debug,
device,
kit,
Qt,
Qt Creator,
Raspberry Pi,
Yocto
Wednesday, November 29, 2017
QWidget: Must construct a QApplication before a QWidget
Have you faced such error message? It's specially likely to appear if you are using Qt framework along with 3rd party libraries. The solution?
Wednesday, November 22, 2017
Emit signals of other objects...
It'll depend on the Qt version you're using. If Qt 5.x it's easy, as signals are public methods. And the 'emit' keyword expands to an empty string, so just both entries below are equivalent:
1. create public method in class A, that will emit necessary signals
2. create signal in class B and connect it to a signal in class A
Given all that said, please remember that it might not be a good idea to emit signals of other objetcs directly.
IMO signals are intended to be emitted by a class as a response to some event, i.e. a QPushButton object will emit the clicked() signal when the user clicks with the mouse on such button. So if you really needs that button to emit the clicked() signal, my approach is to provoke the right event so that signal is finally emitted. Following this example, you need to call QPushButton.click() method instead of emitting the signal directly, but having the exact same behavior as a result of the object's reaction to a particular event.
Happy coding!
a.signal_X();
emit a.signal_X();If using Qt 4.x, it's not that easy since signals are protected methods so you can't emit signals directly. However, there are a couple of approaches to achieve that:
1. create public method in class A, that will emit necessary signals
2. create signal in class B and connect it to a signal in class A
Given all that said, please remember that it might not be a good idea to emit signals of other objetcs directly.
IMO signals are intended to be emitted by a class as a response to some event, i.e. a QPushButton object will emit the clicked() signal when the user clicks with the mouse on such button. So if you really needs that button to emit the clicked() signal, my approach is to provoke the right event so that signal is finally emitted. Following this example, you need to call QPushButton.click() method instead of emitting the signal directly, but having the exact same behavior as a result of the object's reaction to a particular event.
Happy coding!
Tuesday, November 21, 2017
QML ListModel is not a QML List Type
As 0 be 1 cannot be (from Star Wars parlance), a QML ListModel is not a list QML Basic Type. Given that said, let's say you have a properly populated ListModel of coordinates (i.e. pairs of latitude and longitude values), and you want to use it as input for a QML MapPolyline to display a polyline in a map...
Labels:
Javascript function,
list QML Type,
ListModel,
Map,
MapPolyline,
Qml
Monday, October 23, 2017
Raspbian: /opt/qt/bin/qmake: cannot execute binary file: Exec format error
If you're cross-compiling Qt for Raspberry Pi (for instance following this guide), and once everything finished and seems Ok, you may encounter the following error while running qmake:
/opt/qt/bin/qmake: cannot execute binary file: Exec format error
/opt/qt/bin/qmake: cannot execute binary file: Exec format error
Labels:
cross-compile,
exec error,
host,
moc,
qmake,
Qt,
Raspberry Pi,
rcc,
RPi,
uic
Subscribe to:
Posts (Atom)
