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

Sunday, April 1st 2012, 5:55pm

How add slot and signal to exist class ?

Hi, i have a problem with adding slot (and signal, to slot work correct).
How can i add slot(and signal if is nessesery) to for example QTabWidget resize (if control change size), double click or click right button mouse ??

M_C_M

Trainee

  • "M_C_M" is male

Posts: 104

Location: GOC

Occupation: SW

  • Send private message

2

Monday, April 2nd 2012, 6:23am

Include QObject class;
Go through Qt helps. http://qt-project.org/doc/qt-4.8/QObject.html
You need to create specific TabWidget inherits from QTabWidget and you can define what ever you like.
an Eye 4 Qt :thumbup:

3

Monday, April 2nd 2012, 10:55am

Ok i try.
Next question. Where i can find Message Loop(if in Qt this is called Message Loop), where i have to put this code ??

// "int temp_width;" This is new attribute my class who inherits from QTabWidget
// in constructor "temp_width = width();"

Source code

1
2
3
4
5
if (temp_width != width())  	
{
  	 	emit resize(temp_width); 
  	temp_width = width();
}

This post has been edited 1 times, last edit by "Pablik" (Apr 2nd 2012, 11:40am)


4

Monday, April 2nd 2012, 12:16pm

look at event handlers

e.g. resizeEvent
http://qt-project.org/doc/qt-4.8/qwidget.html#resizeEvent


by the way, I think you will run into problems if you try and take widget size in widget ctor - I think Qt won't calculate all these things until widget is shown.

Anyway, I think it looks like you are doing something strange here - resizing should be done by layouts or by animation - you probably shouldn't be doing these things 'manually'
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar threads