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. Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise

Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 8 Posters 1.1k Views
  • 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.
  • I icebergenergy

    Once again, I want to keep C++ syntax, and use QT for executing C++ functions.
    What is good option to output binary files with QT?
    Qlabel?

    Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #8

    @icebergenergy said in Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise:

    I want to keep C++ syntax, and use QT for executing C++ functions.

    You're aware that Qt is a C++ library? So your statement somehow doesn't make sense.
    @JonB asked about your real problem - what's your task you're stuck in? What did you try? What do you want to achieve?

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    1
    • I Offline
      I Offline
      icebergenergy
      wrote on last edited by
      #9

      I need to output DAT file lines to QT Window, all calculations in DAT files, output in GUI.

      [1] Find Interface to output
      [2] On button click - read from DAT file function
      [3] Output Line By Line to GUI interface [1]

      Read with C++ syntax
      Output to GUI with Q Syntax

      I have system working without GUI, I need GUI, need be to implemented step by step.
      Where Q syntax is MUST I will go deep dive and transit there, if not I will keep C++ syntax

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #10

        And what did you try so far? Where are your problems? There are a lot of examples on how to build a simple Qt GUI application out there.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • I Offline
          I Offline
          icebergenergy
          wrote on last edited by
          #11

          I've tried QLabel, I think it will be fine.
          But I need proper sample.
          So I'm here for your kind advise.
          Need to output 4 columns from DAT file
          BR

          Dima

          Christian EhrlicherC 1 Reply Last reply
          0
          • I icebergenergy

            I've tried QLabel, I think it will be fine.
            But I need proper sample.
            So I'm here for your kind advise.
            Need to output 4 columns from DAT file
            BR

            Dima

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #12

            @icebergenergy said in Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise:

            But I need proper sample.

            I gave you a link to a lot of samples. Start with a basic one to get some ideas on how it works, then try to add your functionality.
            Noone will write the code for you here.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • I Offline
              I Offline
              icebergenergy
              wrote on last edited by
              #13

              @Christian-Ehrlicher said in Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise:

              And what did you try so far? Where are your problems? There are a lot of examples on how to build a simple Qt GUI application out there.

              Bro, I've researched your link, and found interesting QTableView as a future library.
              What do you think of QTableView in regard to my case?

              JonBJ 1 Reply Last reply
              0
              • I icebergenergy

                @Christian-Ehrlicher said in Need to build QT GUI using my C++ code. I want to be more C++ and less QT. Please advise:

                And what did you try so far? Where are your problems? There are a lot of examples on how to build a simple Qt GUI application out there.

                Bro, I've researched your link, and found interesting QTableView as a future library.
                What do you think of QTableView in regard to my case?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #14

                @icebergenergy
                It's not clear (to me at least) what is in your "DAT file", and what you want to output/appear in a GUI.

                If you have some kind of (text) file with lines and multiple "fields" per line, separated somehow --- ahh, I see, 100 Donald Trump 777 --- and you would like to display it as rows (for the lines) and columns (for the fields), then a QGridView or QTableView might be good choices.

                These two are both "visual" (hence the word "view" at the end). You have to provide the data you want them to show in a suitable form. In the case of a QTableView that needs a model for its data. The model holds rows & columns of data, the view is attached to the model and displays it.

                Have a look at QTableWidget. That is a QTableView (for viewing) plus an internal model (for the data) combined into one widget. Read the lines from your file, split into appropriate fields, put that data into the QTableWidget as you go and it will display as rows & columns.

                1 Reply Last reply
                5
                • S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #15

                  I agree with @JonB. The decision if you want to use QTableWidget or QTableView mostly depends on how many lines you expect to display. The easy approach is to use a QTableWidget with setItem(). setItem needs a QTableWidgetItem and its constructor takes a string (QString, obviously). So you can do a loop over all your data, construct QTableWidgetItems and place them in the table widget.

                  If you don't do that too often (i.e. data does not change) and if you don't have to many items, this approach will work just fine. Otherwise you'll need a QTableView (QTableWidget actually derives from it) together with a model. For the model you have to derive from the proper class and overwrite the method that will yield the data for a column/row pair. How you retrieve the data is again up to you (just use plain C++ without Qt for the retrieval).

                  JonBJ 1 Reply Last reply
                  1
                  • S SimonSchroeder

                    I agree with @JonB. The decision if you want to use QTableWidget or QTableView mostly depends on how many lines you expect to display. The easy approach is to use a QTableWidget with setItem(). setItem needs a QTableWidgetItem and its constructor takes a string (QString, obviously). So you can do a loop over all your data, construct QTableWidgetItems and place them in the table widget.

                    If you don't do that too often (i.e. data does not change) and if you don't have to many items, this approach will work just fine. Otherwise you'll need a QTableView (QTableWidget actually derives from it) together with a model. For the model you have to derive from the proper class and overwrite the method that will yield the data for a column/row pair. How you retrieve the data is again up to you (just use plain C++ without Qt for the retrieval).

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #16

                    @SimonSchroeder
                    Agreed. I suggested QTableWidget rather than QTreeView for this OP as I think he is looking for a simple solution and this avoids him having to write a model himself for a QTreeView.

                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      Dan203
                      wrote on last edited by
                      #17

                      Just use the designer to create .ui files for the dialogs you need. There is a simple API to load these files as a class and every control has simple method for setting/reading it's value. Requires very little code.

                      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