I am trying to reuse a combo box over multiple tabs (keeping the same entries and selection).
I’ve tried using the methods Clone() and Copy(), and neither work. From what I gather, it is not possible to share a widget with different parent frames. So I guess a deep copy is what I want. fCombo1 and fCombo2 are in separate tabs.
The original combo box is defined as:
TGComboBox *fCombo1 = new TGComboBox(fBottom1, 88);
int i;
char tmp[28];
for (i = 0; i < 28; i++)
{
sprintf(tmp, "Channel %i", i+1);
fCombo1->AddEntry(tmp, i+1);
}
fBottom1->AddFrame(fCombo1);
fCombo1->Resize(90,20);
Using Copy():
TGComboBox *fCombo2 = new TGComboBox(fBottom2, 88);
fCombo1->Copy(*fCombo2);
fCombo2->ReparentWindow(fBottom2);
fBottom2->AddFrame(fCombo2,buttonLayout);
This makes a combo box in the next tab, but it is not of the same size (unless I call Resize again) and is empty.
Using Clone():
TGComboBox *fCombo2 = (TGComboBox*)fCombo1->Clone();
fCombo2->ReparentWindow(fBottom2);
fBottom2->AddFrame(fCombo2,buttonLayout);
This produces the same results as before, but it now gives me this message:
Error in TGWidget::Streamer: version id <=0 in ClassDef, dummy Streamer() called
Error in TGWidget::Streamer: version id <=0 in ClassDef, dummy Streamer() called
Error in TGWidget::Streamer: version id <=0 in ClassDef, dummy Streamer() called
Error in TGWidget::Streamer: version id <=0 in ClassDef, dummy Streamer() called
Using ‘=’ operator:
*fCombo2 = *fCombo1;
fCombo2->ReparentWindow(fBottom2);
fBottom2->AddFrame(fCombo2,buttonLayout);
This gives an error:
Error: can not call private or protected function myGUI.C:135:
/usr/local/root/lib/libHistPainter.so -1 TGCompositeFrame& TGCompositeFrame::operator=(const TGCompositeFrame&);
Calling : TGCompositeFrame::operator=(TGComboBox);
Match rank: file line signature
- 10002 /usr/local/root/lib/libHistPainter.so -1 TGCompositeFrame& TGCompositeFrame::operator=(const TGCompositeFrame&);
*** Interpreter error recovered ***
Any ideas?