Results 1 to 4 of 4

Thread: How to change the existing color of an object

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to change the existing color of an object

    Hi,

    I have a serious problem in changing the existing color of an object when a particular function is called.
    I have designed a GUI to control the Khepera Robot. I have designed this GUI using Qt Designer as well as coding. The object which for which I need to change the colour, I have drawn it using code. Actually I have drawn a circle with two rows of rectangles, each row with 8 rectangles along the circumfrence of the circle. These rectangles represent the sensors ( 8 Ambient sensors and 8 proximity Sensors). I have given two different colours to each row of rectangles. My aim is to change the colour of the rectangles in each row when their respective function for reading the ssensors is called. I am prsenting below my code for GUI which I have written. Fucntions to read sensors getAmbientSensors() and getProximitySensors() are implemented in KheperaiiInterface.cpp which is a robot functioning code.

    Actually the problem is where I should call these two functions. I thought of writing like this in MoveRobot constructor...

    Qt Code:
    1. QTimer *timer = new QTimer(this);
    2. connect (timer, SIGNAL(timeout()), this, SLOT(getAmbientSensors()));
    3. timer->start(1000);
    To copy to clipboard, switch view to plain text mode 

    For every 1000ms the timer updates and it calls the function getAmbientSensors() which returns the ambient sensors. Now my problem is where to write the function to change the existing color of the rectangles representing 'Ambient Sensors' of the robot. I think, I can write this function only in paintEvent() but how to write it and what is the synatax of this? Please help me in this regard. If you don't understand my question properly please reply me, I will try to explain you in a better way.



    Please help me by suggesting me a good solution in this regard.

    Your help would be a great relief to me as the final date to sub,mit my project is very near.

    With Regards
    Thirupathi Uppu
    Attached Files Attached Files
    Last edited by wysota; 7th February 2008 at 20:57. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.