Unsolved multiple inheritance
-
well, i wanna try to give that button some properties.
i need to access the button properties.
just trying some stuff.what do you suggest?
-
@Natural_Bugger
It's difficult to know, because I have no idea what you are thinking of conceptually....Why are you going anywhere near threads at all? They add a lot of complexity, what use case do you have here for threads?
how do i make random numbers appear on the button every x time?
Maybe use a
QTimer
to change the text on the button over time??Or, if you really, really have a thread generating random numbers all the time and you want to display them, use the pattern that the worker thread raises signals with the desired number/text and the main UI thread has a slot for the signal which updates whatever on the UI.
-
Well, just want to say that multiple inheritance of classes which inherit QObject is not allowed.
-
i would like to make the button fall at a rate of 9.81 pixels per second and if i lift it up again.
so my guess: is that my button needs to check autonomously where it resides. -
@Bonnie raises a good point: you cannot inherit twice from anything inheriting from
QObject
. So you won't getclass CustomButton : public QPushButton, public QThread
to work anyway, which is just as well! :) -
@Natural_Bugger said in multiple inheritance:
i would like to make the button fall at a rate of 9.81 pixels per second and if i lift it up again.
Not that I know what this means, but it sounds like you want a 1-second repeating
QTimer
in which you do some update to the UI? -
@Natural_Bugger I'm surprised this compiled
https://doc.qt.io/qt-5/moc.html#multiple-inheritance-requires-qobject-to-be-first
Inheriting from multiple QObjects is not allowed/supported
-
it actually runs.
mybutton->start(); // <---
if i comment out "mybutton->start(); // <---", the run function doesn't work, otherwise it does.
-
it's just an experiment.
trying to give the button some "life" -
@Natural_Bugger
Well, it's the wrong experiment! Conceptually widgets and threads have nothing to do with each other. What's wrong with aQTimer
, which sounds like all you are looking for? -
Hi
For such animations, you can also use
https://doc.qt.io/qt-5/qpropertyanimation.html