tooth
23rd November 2010, 18:27
I'm just getting started again with c++/Qt working on a project.
I have a class the just lays out a widget with a button and a line edit field.
I'll be creating an instance of this object in another class (mainwindow), and will need to make some connections with the buttons. Is it bad form to make these buttons public? The below works great, solves my problem, but I would rather do it the right way. Or should I just go about creating signals and slots for these objects and make them private? Thanks for advice :)
class CustomWidget : public QWidget
{
Q_OBJECT
public:
explicit CustomWidget(QWidget *parent = 0);
QPushButton *pushButton;
QLineEdit *lineEdit;
private:
QVBoxLayout *vLayout;
QHBoxLayout *hLayout1;
QHBoxLayout *hLayout2;
// QLineEdit *lineEdit;
// QPushButton *pushButton;
};
I have a class the just lays out a widget with a button and a line edit field.
I'll be creating an instance of this object in another class (mainwindow), and will need to make some connections with the buttons. Is it bad form to make these buttons public? The below works great, solves my problem, but I would rather do it the right way. Or should I just go about creating signals and slots for these objects and make them private? Thanks for advice :)
class CustomWidget : public QWidget
{
Q_OBJECT
public:
explicit CustomWidget(QWidget *parent = 0);
QPushButton *pushButton;
QLineEdit *lineEdit;
private:
QVBoxLayout *vLayout;
QHBoxLayout *hLayout1;
QHBoxLayout *hLayout2;
// QLineEdit *lineEdit;
// QPushButton *pushButton;
};