I'm transitioning from Visual BASIC to Qt.
Let's say I want to have a button change colour when it's clicked. How do I arrange for the click to trigger a function that changes its colour?
I'm transitioning from Visual BASIC to Qt.
Let's say I want to have a button change colour when it's clicked. How do I arrange for the click to trigger a function that changes its colour?
You need to use a feature called "signals and slots". Open Qt Assistant and enter "Signals and Slots" into the index tab.
OK, interesting...
I connect my button's "clicked()" signal to its own "click()" slot, and I have myButton::click() change the colour? Or do I have to make a custom slot (and to do that do I need to make a custom "myQButton" class)?
Basically, can I have my button change colour by editing only main.cpp and mainWidow.cpp?
Last edited by Envergure; 25th November 2008 at 16:07.
http://doc.trolltech.com/4.4/index.html is your best friend. I use it on a daily basis.
fnmblot
--------------------------------------
Gee Ricky, I'm sorry your mom blew up.
You need to create your own custom slot somewhere (like in mainWindow.cpp) and connect the signal to it. Inside the slot you need to perform the changes you want.
Yay, it's working!
I had to call my button by "ui.pushButton" instead of just "pushButton". Otherwise I got "pushButton not declared in this scope."
Bookmarks