How to put a pixel on window?



  • 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


  • Moderators

    @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.



  • @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();
    

    }


  • Moderators

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.