You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, December 23rd 2004, 3:50am

Stupid Newbie Questions

I'm working my way through the tutorials and I'm stuck on the exercise part of the fifth one ( http://doc.trolltech.com/3.3/tutorial1-05.html ). Its just a slider connected to an lcd but I'm trying to add buttons that will set a value like 50 or 75. Do I have to overload the class with something like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
class myButton : public QPushButton
{
	Q_OBJECT
	signals:
		void clicked(int num);
};

void myButton::clicked(int num)
{
	emit clicked(num);
}



Otherwise how do I make the arguements for QPushButton::clicked() and QLCDNumber::display(int) match so I can use connect?

Thanks

2

Thursday, December 23rd 2004, 4:45am

I am sorry to Say

But that code doesn't make sense.

What is your intention.
And Signals are not implemented.

You have aSignal called Clicked ( int ) ; and that is being Implemented ??

Please Explain
Check this 4m out http://QtCentre.Org - The Qt Community Centre

3

Thursday, December 23rd 2004, 5:42am

I'm not surprised my code does not make sense. I'm still getting used to Qt's moc and the altering of C++....but whatever.

What I'm trying to do in my program is to make a button that once clicked will change the value in a QLCDNumber widget?

From what I have read about Qt's signals and slots is that the parameters of both must match for them to work properly. So I cannot use SIGNAL(clicked(void)) and SLOT(display(int)).

And what do you mean that signals will never be impliented? Sigh...to being confused.

4

Thursday, December 23rd 2004, 6:23am

OK
Do you want the button to be a Part of the Widget Just like the Slider Or Do you want the Button to be A Seperate Widget That Interacts with the LcdSlider Widget ?


if It is a Part of Widget then Add a QPushButton * to the LcdSlider and
Create a Slot may be f oo () {
}
Connected the Click Signal to the foo () & with in
foo () {
display ( 25 ) ;

}

if a Signal needs to be Generated
Then Create a signal clicked ( int ) and then emit it inside the foo ()

But please note that you must keep the emit inside an if ( ... ) so as to Avoid any Cyclic Calls



My Suggestion to U is to Do what is told in the tutorial and try repeating it!.
This will help U get aquainted with the concept of Signal & Slot ;

There are Events also. This will follow shorty.

When you are done with the tutorial and understood the Concepts then Start Experimenting . I think this will be better and more Productive than trying to do thing with little knowledge.

Please don't misunderstand me.
This is what i do. I study a concept, imitate, then Experiment

There is also a good tutorials at www.digitalfantastic.org
I hope you know that the official book by Trolltech is free for download

Don't Create an aversion for QT. Believe me This is one of the best frame works you can ever get
Check this 4m out http://QtCentre.Org - The Qt Community Centre