You are not logged in.

Dear visitor, welcome to 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.


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" is male

Posts: 104

Location: GOC

Occupation: SW

  • Send private message


Monday, April 2nd 2012, 6:23am

Include QObject class;
Go through Qt helps.
You need to create specific TabWidget inherits from QTabWidget and you can define what ever you like.
an Eye 4 Qt :thumbup:


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

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)


Monday, April 2nd 2012, 12:16pm

look at event handlers

e.g. 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