Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Effect of QApplication for a console application.

    General and Desktop
    4
    8
    4221
    Loading More Posts
    • 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
      selcuk last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        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 Reply Quote 0
        • S
          selcuk last edited by

          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 Reply Quote 0
          • A
            andre last edited by

            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 Reply Quote 0
            • Z
              ZapB last edited by

              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 Reply Quote 0
              • A
                andre last edited by

                [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 Reply Quote 0
                • Z
                  ZapB last edited by

                  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 Reply Quote 0
                  • G
                    giesbert last edited by

                    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 Reply Quote 0
                    • First post
                      Last post