Qt Forum

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

    Unsolved How to put a pixel on window?

    Mobile and Embedded
    pixel dot
    2
    4
    1597
    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.
    • hjpark
      hjpark last edited by

      Hi Guys..

      I want to draw a RGB pixel on a window.
      but.. I dont find an API like a putPixel on C lib.

      Could you let me know how to put a RGB pixel on a window?
      thanks a lot
      HJ

      ? 1 Reply Last reply Reply Quote 0
      • ?
        A Former User @hjpark last edited by

        @hjpark Hi, and welcome to the Qt forum! Simply derive from QWidget and override its paintEvent method. You can then draw whatever you want inside there.

        hjpark 1 Reply Last reply Reply Quote 0
        • hjpark
          hjpark @Guest last edited by hjpark

          @Wieland Thanks a lot for your help.. I succeeded to draw a point with this code but I have to draw a point whenever getting some datas from a USB device. but, I don't know how to raise paintEvent manually when I want.
          It seems to be called when the widget showed but I don't know how to call paintEvent when I get a data from USB devie. pls help me again . thanks a lot.

          void Widget::paintEvent(QPaintEvent *event)
          {
          Q_UNUSED(event);

          QPainter painter;
          painter.begin(this);
          
          painter.setPen(Qcloor(10,10,10);
          painter.drawPoint(10,10);
          painter.end();
          

          }

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            Once you received new data and want the widget to be painted again just call this function on it: [slot] void QWidget::update(), see also: QWidget Class.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post