Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Troubles with simple example
Forum Updated to NodeBB v4.3 + New Features

Troubles with simple example

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 388 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rock37
    wrote on last edited by
    #1

    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

    Pl45m4P SGaistS 2 Replies Last reply
    0
    • R rock37

      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

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @rock37

      You dont seem to create any main event loop for your QApp... without the loop, Qt won't work properly.
      It's used for Qt's event system, to be able to process user input and to communicate with the window system.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • R rock37

        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

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply
        1
        • SGaistS SGaist

          @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.
          R Offline
          R Offline
          rock37
          wrote on last edited by
          #4

          @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 ?

          R 1 Reply Last reply
          0
          • R rock37

            @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 ?

            R Offline
            R Offline
            rock37
            wrote on last edited by
            #5

            @rock37 do i need to inherit from another class also or do i just need to implement the event(QEvent *e) function ?

            SGaistS 1 Reply Last reply
            0
            • R rock37

              @rock37 do i need to inherit from another class also or do i just need to implement the event(QEvent *e) function ?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              Pl45m4P 1 Reply Last reply
              2
              • SGaistS SGaist

                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 ?

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #7

                @SGaist

                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 with app.exec() I don't think it will work.
                But you still have QApplication::instance() to do something more "fancy"


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved