button->connect member functions

  • 4 Replies
  • 309 Views
button->connect member functions
« on: 24 March 2019, 16:54:34 »
Hi, I'm creating a GUI for an application used to create random level layouts.

I'm trying to connect a button using member functions and member variables. I tried following some other topics and the introduction to signals post but to to avail.

Here is some code to show what I'm trying to do:
   
Code: [Select]
m_buttonGenerateRW->connect("pressed", &App::generateRW,
&instance,
m_ebMaxWalkers,
m_ebFillPercentage,
m_ebChanceToChangeDirection,
m_ebChanceStartAlive,
m_ebChanceToDestroyWalker,
m_ebChanceToSpawnNewWalker);

Code: [Select]
m_buttonGenerateCA->connect("pressed", &App::generateCA,
&instance,
m_ebNumSimulationSteps,
m_ebBirthLimit,
m_ebDeathLimit,
m_ebChanceStartAlive);

Any help would be greatly appreciated,

Simon

*

texus

  • *****
  • 1475
    • View Profile
    • Texus's Blog
Re: button->connect member functions
« Reply #1 on: 24 March 2019, 17:01:12 »
Can you show the declarations of generateRW, generateCA, instance and the other parameters you are passing?

Re: button->connect member functions
« Reply #2 on: 24 March 2019, 17:04:49 »
Yes of course

Code: [Select]
App instance;

Code: [Select]
void generateRW(tgui::EditBox::Ptr ebMaxWalkers,
tgui::EditBox::Ptr ebFillPercentage,
tgui::EditBox::Ptr ebChanceToChangeDirection,
tgui::EditBox::Ptr ebChanceToDestroyWalker,
tgui::EditBox::Ptr ebChanceToSpawnNewWalker);
Code: [Select]

void generateCA(tgui::EditBox::Ptr ebNumSimulationSteps,
tgui::EditBox::Ptr ebBirthLimit,
tgui::EditBox::Ptr ebDeathLimit,
tgui::EditBox::Ptr ebChanceStartAlive);

Simon

*

texus

  • *****
  • 1475
    • View Profile
    • Texus's Blog
Re: button->connect member functions
« Reply #3 on: 24 March 2019, 17:09:47 »
The parameters for generateRW don't match, in the connect function you pass one parameter too much, the m_ebChanceStartAlive.

The generateCA line looks fine, assuming the edit boxes are declared like this in the App class:
tgui::EditBox::Ptr m_ebNumSimulationSteps;

Can you show the full errors you get on the m_buttonGenerateCA->connect call?

Re: button->connect member functions
« Reply #4 on: 24 March 2019, 17:16:23 »
Ah, the error was what you caught with the extra parameter while connecting the buttonGenerateRW, seems to work fine now.
Thanks for your help and for creating a great tool for making GUIs.

Simon.