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. Loading images or draw them?? witch one is faster?
QtWS25 Last Chance

Loading images or draw them?? witch one is faster?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 6 Posters 1.5k 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.
  • A Offline
    A Offline
    arsinte_andrei
    wrote on last edited by
    #1

    So, I'd like to make some custom widgets for weather application and I just wish to know what is the best option to do them and how... by using QPainter and start painting the object or by using a png image with QPixmap?

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

      A QPixmap must also be painted ... so what should be the difference? If you want to draw a picture you must first load it or paint it by yourself. Painting the image directly in the paintEvent will for sure take more time - esp. since the image won't change as often as paintEvent is (maybe) called I would guess.

      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
      2
      • A Offline
        A Offline
        arsinte_andrei
        wrote on last edited by
        #3

        hmm... that is bed news for me... I do prefer to design things in Krita or Inkscape... but to draw them in C++... that is another story.. how can I draw a moon?? what to use to do it?? just a normal white moon-shape

        JKSHJ W 2 Replies Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          How many times per second do you expect your application to refresh its content ?

          How big are your images ?

          One possibility is also to compose a QPixmap with the various information you want and put it in a QLabel to be shown.

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

          1 Reply Last reply
          2
          • A arsinte_andrei

            hmm... that is bed news for me... I do prefer to design things in Krita or Inkscape... but to draw them in C++... that is another story.. how can I draw a moon?? what to use to do it?? just a normal white moon-shape

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @arsinte_andrei said in Loading images or draw them?? witch one is faster?:

            I just wish to know what is the best option to do them and how...

            The best option is usually the simplest option. Don't worry about which one is "faster" unless the simplest option causes problems.

            @arsinte_andrei said in Loading images or draw them?? witch one is faster?:

            I do prefer to design things in Krita or Inkscape... but to draw them in C++... that is another story.. how can I draw a moon?? what to use to do it?? just a normal white moon-shape

            In this case, you should use Krita and Inkscape to draw your moon.

            that is bed news for me...

            Why is it bad news? Loading a .png image is a perfectly good approach.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            2
            • A Offline
              A Offline
              arsinte_andrei
              wrote on last edited by
              #6

              this is what I wish to build up is Qt c++ (sorry no Qt quick as I have no idea what is it and how to use it - I have more control in c++ where I can implement all the animation that I need)

              0_1561237989937_claydons.png

              the refresh rate is set to about 1 minute so... and is a weather station running on raspberry pi
              (BTW if anyone is interested in the project I do offer it for free GPL2/3 not decided yet)
              is to control smart home systems - written in Qt and cloudless (you can add cloud if you want) freedom is the core of it...

              anyway enough with advertising.. now, how do you recommend to do it??
              in my opinion I'm trying to do something similar at look to it - and with each widget to receive its own data and to represent it

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

                Hi
                is this for a desktop application or a mobile one? (or both)

                A 1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Go with @JKSH's suggestions. Just take into account that you don't need super high definitions of your images unless you are driving a 4k screen which is unlikely with a current RPi.

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

                  1 Reply Last reply
                  2
                  • mrjjM mrjj

                    Hi
                    is this for a desktop application or a mobile one? (or both)

                    A Offline
                    A Offline
                    arsinte_andrei
                    wrote on last edited by
                    #9

                    @mrjj
                    is for raspberry pi with the 7" display
                    so basically I'm using a raspberry pi in each room as the main controller: from here you can access all the info like audio, weather, lights, blinds, etc...
                    In the house is also a server that communicates with all the sensors and reply back to the raspberry pi

                    1 Reply Last reply
                    0
                    • A arsinte_andrei

                      hmm... that is bed news for me... I do prefer to design things in Krita or Inkscape... but to draw them in C++... that is another story.. how can I draw a moon?? what to use to do it?? just a normal white moon-shape

                      W Offline
                      W Offline
                      wrosecrans
                      wrote on last edited by
                      #10

                      @arsinte_andrei said in Loading images or draw them?? witch one is faster?:

                      hmm... that is bed news for me... I do prefer to design things in Krita or Inkscape... but to draw them in C++... that is another story.. how can I draw a moon?? what to use to do it?? just a normal white moon-shape

                      It sounds like there may have been a miscommunication if you feel that you've gotten bad news. The act of taking an image loaded into memory and putting it on screen is called "painting" and you use QPainter to do it. Regardless of whether you are drawing lines and circles using the API, or copying a buffer from a pixmap that started out as a PNG image.

                      As for the fastest way to do it... Just start with the simplest way, and see if that's fast enough. Only worry about solving the problems you have. A Raspberry Pi is obviously a lot slower than a desktop system so you are more likely to run into performance problems there. But it makes more sense to start with a simple prototype, and profile what the slow parts are, rather than worry about things you imagine could potentially be slow and spend your time working on stuff that may not actually have been a problem.

                      1 Reply Last reply
                      3

                      • Login

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