Same shape different colour
Hi All
I have a question ,If you answer this ,i will be very appreciate.
I want to use 5 pushbuttons on my frame with special shape (circular) by promoting . But the question is i want these button same shape but different colour. Have may i paint these buttons with different colour?I have prepared a class which is indicated in buton.h file and "paintEvent" is written in buton.cpp file. I promoted my buttons in designer by right click and "promote" -> "Buton.h". the problem is I have 5 buttons but 1 class and 1 paintEvent function. How may i paint may buttons with different colour,by using same paint event? Do i have to indicate different classes for every button?
"buton.h file"
Code:
#ifndef BUTON_H
#define BUTON_H
#include <QPushButton>
{
Q_OBJECT
public:
protected:
};
#endif
"buton.cpp file"
Code:
#include "buton.h"
{
}
void buton
::paintEvent(QWidget *pe
) {
//May I use this place for different 5 buttons?
}
Re: Same shape different colour
Store the color as a member variable.
Re: Same shape different colour
can you give me an instance?
Re: Same shape different colour
Quote:
Originally Posted by
anafor2004
can you give me an instance?
Sorry, but I'm not going to spoon feed you. Please consult your favorite C++ book. You really have to know the basics of C++ and OOP before you can start working with Qt.
Re: Same shape different colour
Dear Anafor!
You can pass colour info. with constructor and store it into a your class. After that you can applied this colour to your paint event.
Sir JPN! has given you a right answer.
You should play with your mind & C++ with Qt.
Re: Same shape different colour