New to Qt! Simple button to control peripherals



  • Hello,

    My name is Jose and I'm new to Qt. I've used C# and C++ before to create very basic UIs, I'm not an expert, but I really like what I see and read about Qt and will like to get familiar with it. Ok done with that!!

    I'm trying to create a simple UI in Qt to communicate via the COM port with a microchip. I already have my own C++ .dll for the COM port, and the microchip side I can take care of.
    So basically I need a button and an indicator for the UI. There will be only two stages ON/OFF and the state must be reflected on the indicator. I've created two indicators (images) using GIMP(I call it "LED_OFF" and "LED_ON") one is black (off) one is green (on).
    So basically when the button is pressed and if the indicator is OFF then a turnON signal will be sent out over the COM port and the opposite when it's on. The indicator on the UI will display the current state at all times.

    Maybe I wrote too much, but I hope someone get's what I'm trying to do and point me in the right direction as to what the best approach to accomplish this with Qt will be. Also I need this to be compatible with Windows XP or greater and Linux (Ubuntu 11.03)



  • Sounds like a perfect job for a custom widget (i.e. custom drawing). You can give a look to the "embedded widgets" demo for inspiration:

    http://qt.nokia.com/qt-in-use/developer/embedded-widget-demos

    (see the links in the lower right corner).



  • "Here":http://qt-apps.org/index.php?xcontentmode=4298, you can find a collection of Qt Widgets you can use. Among them, are a few LED-type widgets. Perhaps you can use those?

    Edit:
    Forgot to actually set the "link":http://qt-apps.org/index.php?xcontentmode=4298 for "Here".



  • would you provide some code?? you can create desktop based button which can communicate via COM port



  • Maybe you need to use ordinary widgets with custom styles? For example a toggle button or radio button...
    I suggest take a look at "Style Sheets":http://doc.qt.nokia.com/latest/qradiobutton.html



  • it would take only less than 30 minutes to do that. in desktop application select form and create two push buttons, right click on button and choose signal and slot(on Clicked()), it will provide you function where you can put your code to pass HEX or binary signal to COM port to set or reset.


Log in to reply
 

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