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. Effect of QApplication for a console application.
Forum Updated to NodeBB v4.3 + New Features

Effect of QApplication for a console application.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 4.7k Views 1 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.
  • S Offline
    S Offline
    selcuk
    wrote on last edited by
    #1

    Hello,

    I have a purely console application, that uses QCoreApplication. But i need to use a library, which uses QTreeWidget as a data structure for one of its results. There is absolutely no visual component displayed, but to use QTreeWidget, qt tells me to make a gui application, so I need to change the application to QApplication. Searched the internet but could not find a posting about the performance issues this switch will bring. Apart from the initialization, is there too much overhead introduced for using QApplication instead of QCoreApplication?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      The main issue, I think, is that you will need a running X server if you run your application on *nix. I don't think there will be much of a performance hit, unless your app is intended to perform a very short task often, and is continuously started and stopped for that purpose. However, the best way to tell is to simply test it on your platform.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        selcuk
        wrote on last edited by
        #3

        thanks for the reply. You just made me realize that converting to QApplication while giving the GUIenable parameter as false in constructor, was not enought to create a QTreeWidget. I have to create a gui application, and as you said, on a unix system, it asks for an X11 server on startup, which i dont have. So performance issue is not a concern any more. Will have to change the library to return a non gui class as result.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Might be a good idea anyway. Using a QTreeWidget as a data structure only doesn't sound like a good idea.

          If you are looking for a tree data structure, then perhaps look into "tree.hh":http://tree.phi-sci.com/. I use it, and it works well. Even wrote a class to make such a tree work as the data source for a QAbstractItemModel.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            You should be able to get at the QTreeWidget's internal model via QAbstractItemView::model().

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              [quote author="ZapB" date="1300281778"]You should be able to get at the QTreeWidget's internal model via QAbstractItemView::model().[/quote]
              Since you can not create a QTreeWidget in a non-gui application, I see no way of getting to the internal model of one anyway then? Also, I am not sure you can actually use it, since the QTreeWidgetItems would expect a working QTreeWidget to be present.

              You might be able to use a QStandardItemModel for the same purpose though. Still, personally, I would avoid using it, especially if you don't intent to use it with a view.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                Oh yeah. Sorry, just me being stupid. I forgot the point was to not use QTreeWidget in anyway. Ignore what I said.

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  If you have a non gui app, why do you return the data as QTreeWidget? QTreeWidget is a UI class, not a data container.

                  It makes much more sense to return a data structure, which can then be used by a model to be displayed in a tree, than returning a UI class for that.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  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