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. How to use Qt methods outside Qt Creator
Forum Updated to NodeBB v4.3 + New Features

How to use Qt methods outside Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 3.0k 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.
  • J Offline
    J Offline
    Jonas25
    wrote on last edited by
    #1

    Hello,
    I don't have much experience in that field yet, please don't be annoyed by my simple question.

    I work on a project in c++ without Qt, and without the Qt Creator (I prefer vim). Now I want to debug my code by drawing some output, therefor I want to use the Qt library.
    Is it possible to write a class in the Qt Creator using the Qt libraries, which should draw some data for me, and use this class in a project outside of the Qt creator and without any dependencies?

    I'm glad to get any helpful link or answer from you! Thanks.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      If you use qt classes you will get some dependencies.
      Depending on what you use of course.

      It is possible to static link so there is no external dlls/so
      but that requires license or open source project.

      But if just for debug. you can just use #defines and "make" options so that the final product won't need any Qt libraries.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jonas25
        wrote on last edited by
        #3

        Thank you for your answer, honestly I'm not even sure what exactely I should google for right now. Do you have any links for me? That would be a great help.

        Or do you think other graphic libraries than Qt fit better for my purpose?

        mrjjM 1 Reply Last reply
        0
        • J Jonas25

          Thank you for your answer, honestly I'm not even sure what exactely I should google for right now. Do you have any links for me? That would be a great help.

          Or do you think other graphic libraries than Qt fit better for my purpose?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Jonas25
          Hi if you explain what u want to draw, then I might have ideas.
          I use GNUPLOt myself for many things but all it depends on what u want to draw :)

          J 1 Reply Last reply
          0
          • mrjjM mrjj

            @Jonas25
            Hi if you explain what u want to draw, then I might have ideas.
            I use GNUPLOt myself for many things but all it depends on what u want to draw :)

            J Offline
            J Offline
            Jonas25
            wrote on last edited by
            #5

            @mrjj Sorry, I should have explained myself better. I want to draw a matrix of numbers in a rectangle, each pixel representing one number. Simply said I get a bitmap as input, and my program will detect the edges. The output is a matrix, the higher numbers of the matrix represent the edges and they should be drawn in white, while lower numbers will be drawn darker.

            mrjjM 1 Reply Last reply
            0
            • J Jonas25

              @mrjj Sorry, I should have explained myself better. I want to draw a matrix of numbers in a rectangle, each pixel representing one number. Simply said I get a bitmap as input, and my program will detect the edges. The output is a matrix, the higher numbers of the matrix represent the edges and they should be drawn in white, while lower numbers will be drawn darker.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Jonas25
              well, that is pretty custom so not
              easy to do with std plotter.

              But if it is only for debug, it will be quite some work for getting it drawn
              you could just output to ascii table and just give them a number for "darkness"

              1 ( 100) | 3 (44) | 4 (255)
              4 ( 120) | 9 (44) | 2 (255)
              5 ( 140) | 3 (44) | 3 (255)
              7 ( 150) | 3 (44) | 4 (255)

              or something like that?

              If you are hooked on really drawing it,
              Make a default Qt GUI and use the other c++ code as
              utility. Meaning Qt is the test program and the
              pure C++ is the engine doing the work.
              As long as u dont use Qt feature in those .cpp / classes, it remains pure.

              But, if you are brand new to Qt, there will be some learning to draw it.
              Its not so much code. but some.

              Alternatively:
              you could try
              http://www.imagemagick.org/Usage/draw/
              Its command line and you could just call it from your program to produce an image.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jonas25
                wrote on last edited by
                #7

                @mrjj thanks a lot for your help! I don't want to use a terminal in the end but really a custom window to show my output, so I try to not use the terminal and therefor no ascii table.

                I already worked quite a bit with qt, so I don't have a problem writing a solution inside the qt creator. What I would wish for is to write a static function "drawImage( Matrix)" that uses Qt to create a simple widget showing the image. Is there a way to use that function outside the Qt environment?

                I will take a closer look at ImageMagick, although I knew that before and I had the feeling it is difficult to implement in a C++ project.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  hi
                  Im not 100% sure I understand the following
                  " is there a way to use that function outside the Qt environment?"

                  If you create a Qt program, it can be used outside Creator.

                  But it will need the Qt libraries to work. So for it to have a window
                  and show your output, it will need Qt. As those are Qt widgets.

                  So not sure what you are asking about?

                  If u mean to use a Qt function in your other c++, you could create a library that uses Qt and export a function drawImage( Matrix) that can do what u like.
                  But if you want a window so bad, why not just make a Qt application ?
                  Its will be same dependencies as a library.

                  ImageMagick would be able to create and plot on image and even show it just
                  by running the command lines tools. but it would not be integrated in your app as such.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Jonas25
                    wrote on last edited by
                    #9

                    Sorry for the late response, I managed to solve my problem without Qt, just in case someone stumbles upon this post.
                    There is a simple library that can solve visual tasks. It is not as powerfull as Qt, but for small applications as I needed SFML provides enough functionality.
                    Still thanks for all the help.

                    mrjjM 1 Reply Last reply
                    0
                    • J Jonas25

                      Sorry for the late response, I managed to solve my problem without Qt, just in case someone stumbles upon this post.
                      There is a simple library that can solve visual tasks. It is not as powerfull as Qt, but for small applications as I needed SFML provides enough functionality.
                      Still thanks for all the help.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      @Jonas25
                      Ok super.
                      SFML is cool.
                      Please mark as solved if possible.

                      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