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. Using hardware acceleration(GPU) for QWidget::paintEvent()
QtWS25 Last Chance

Using hardware acceleration(GPU) for QWidget::paintEvent()

Scheduled Pinned Locked Moved Unsolved General and Desktop
gpu acceletatorgpuqwidgetqpainteventqpainter
6 Posts 2 Posters 4.3k 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.
  • S Offline
    S Offline
    SilverSurfer
    wrote on 6 Feb 2018, 07:34 last edited by
    #1

    How would I convert below code to use hardware rendering ?

    1. My BaseWidget class has to be a custom QWidget.
    2. Do I have to perform hardware checks before writing any GPU related code?
    3. Will OpenGLWidget help ?
    BaseWidget::BaseWidget()
    {
      ...
    m_pCanvas = new QWidget;
    m_pQVBoxLayout->addWidget(m_pCanvas);
    this->setLayout(m_pQVBoxLayout); 
        ...
    }
    
    //supposed to be called 30 times a second.
    BaseWidget::getImageData(uchar* buf, size_t size)
    {
        m_pQPixmap->loadFromData(buf,size,"BMP");
        this->update();
    
    } 
    BaseWidget::paintEvent()
    {
    ...
            painter.drawPixmap(rect,*m_pQPixmap,
                          m_pQImage->rect());
    ...
    }
    
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2018, 07:40 last edited by
      #2

      Hi,

      1. Why ?
      2. Depends on your target
      3. Might be. QWidget doesn't use hardware acceleration.

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

      S 1 Reply Last reply 6 Feb 2018, 10:31
      1
      • S SGaist
        6 Feb 2018, 07:40

        Hi,

        1. Why ?
        2. Depends on your target
        3. Might be. QWidget doesn't use hardware acceleration.
        S Offline
        S Offline
        SilverSurfer
        wrote on 6 Feb 2018, 10:31 last edited by
        #3

        @SGaist

        Thanks for the reply

        1. Has to be a QWidget because the host software API takes Qwidget object as an argument.
        2. I guess OpenGL should relieve me of that checks.
        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 6 Feb 2018, 21:12 last edited by
          #4
          1. If you are sure that the target has a GPU.

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

          S 1 Reply Last reply 8 Feb 2018, 06:50
          0
          • S SGaist
            6 Feb 2018, 21:12
            1. If you are sure that the target has a GPU.
            S Offline
            S Offline
            SilverSurfer
            wrote on 8 Feb 2018, 06:50 last edited by
            #5

            @SGaist
            Yes it does have a GPU.

            What does Qt use for drawing on Windows? GDI ?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 8 Feb 2018, 22:25 last edited by
              #6

              It uses the raster engine. See here for historical informations.

              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
              0

              6/6

              8 Feb 2018, 22:25

              • Login

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