Troubles with simple example
-
Hey folks,
i try to create a simple Application class based on QApplication but it compiles and links but when i run it i get: https://paste.debian.net/1307990/The code can be viewed here: https://onlinegdb.com/_Vl_lBUh2
-
Hey folks,
i try to create a simple Application class based on QApplication but it compiles and links but when i run it i get: https://paste.debian.net/1307990/The code can be viewed here: https://onlinegdb.com/_Vl_lBUh2
-
Hey folks,
i try to create a simple Application class based on QApplication but it compiles and links but when i run it i get: https://paste.debian.net/1307990/The code can be viewed here: https://onlinegdb.com/_Vl_lBUh2
@rock37 Hi,
Beside the correct point made by @Pl45m4, QApplication is a class that seldom needs to be subclassed all the more the way you do it.
I would recommend using the standard scaffolding:
- Create your custom widget
- Have a main function that creation the QApplication object, widget, show the widget and call
exec
on the QApplication object.
-
@rock37 Hi,
Beside the correct point made by @Pl45m4, QApplication is a class that seldom needs to be subclassed all the more the way you do it.
I would recommend using the standard scaffolding:
- Create your custom widget
- Have a main function that creation the QApplication object, widget, show the widget and call
exec
on the QApplication object.
-
@SGaist how to implement a correct way to inheriting from QApplication ? i mean it's the base class of my application, i really want it to be that way. how do i create the main event loop ?
-
@rock37 do i need to inherit from another class also or do i just need to implement the event(QEvent *e) function ?
As @Pl45m4 already wrote, you never call
app.exec()
;However your implementation is still wrong. Why are you inheriting from QApplication and then have a class member variable containing an instance of QApplication ?
Your design does not really make sense.
Why do you want to subclass QApplication ? And why are you trying to put your widgets in there ?
-
As @Pl45m4 already wrote, you never call
app.exec()
;However your implementation is still wrong. Why are you inheriting from QApplication and then have a class member variable containing an instance of QApplication ?
Your design does not really make sense.
Why do you want to subclass QApplication ? And why are you trying to put your widgets in there ?
I think @rock37 planned to create something like an IObject Design Pattern with an "Application" Interface.
I'm not sure if this will ever work in an environment like this and if this doesn't break Qt Event system.
Even withapp.exec()
I don't think it will work.
But you still haveQApplication::instance()
to do something more "fancy"