[Qt-interest] Encapsulates question.

phil prentice philp.cheer at talktalk.net
Thu Aug 12 14:44:48 CEST 2010


Hi
  I would like to clarify how I should do something using QT.

  I have a class that encapsulates an array of custom objects i.e.

class Fred
{
  ...
  private:
    Mike mike[6];	// Custom widgets.
    void func1(int index);
}
  I want to catch mouse events in mike and call a private function in Fred.
  So I assume that I should use a signal to interface between mike and fred.

  i.e.
 void Mike::mousePressEvent(QMouseEvent *event)
{
  // Setup widgets for the trace adjustment group (uses current net).
  emit testSelected(index);
}

Correct so far?

Now the index I wish to pass back is to identify which widget was selected.
How best to do this?
Should I use objectName() to identify the object in mousePressEvent or is 
there a better way? Or should I pass the this pointer and let Fred find it by 
searching the array list?

Thanks

Phil

    



More information about the Qt-interest-old mailing list