I want to transfer values from Panel1 EditBox 1 to Panel2 Editbox1.

This is how i get Values from editbox [its Texus code]:
Code: [Select]
// this works, i used same thing to get values and to write them on .txt file
tgui::Panel::Ptr Group1 = gui.get("Group1");
EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i)); // get EditboxNames
Group1Names.push_back(EditBoxNames[i]->getText());        // getText from editboxes
// but i cant transfer those values into another panel

tgui::Panel::Ptr Group1Napomene = gui.get("Group1Napomene");  // get Group1Napomene
                                                                                                            // which is another panel

Ime1napomene->setText(Group1Names));

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Is Ime1napomene supposed to be an edit box or just some text?
Right now it is an sf::String, which doesn't has the setText function.

If it is supposed to be a string like it is now, then the line should be
Code: [Select]
Ime1napomene = Group1Names;

= Group1Napomene->get("Ime" + tgui::to_string(i));
// to get EditBoxes named "Ime" from Group1Napomene. Even if i add that i have same error i posted above.


*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Is that code inside a for loop?
I think this is what you are trying to do:
Code: [Select]
Ime1napomene[i]->setText(Group1Names[i]);

It compiles but i get Core dumped.

DBG said this line is error:
Code: [Select]
Ime1napomene[i]->setText(Group1Names[i]);
Code: [Select]
for (unsigned i = 0; i < 30; ++i)
    {
    tgui::Panel::Ptr Group1 = gui.get("Group1");
    EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i));
    Group1Names.push_back(EditBoxNames[i]->getText());

    tgui::Panel::Ptr Group1Napomene = gui.get("Group1Napomene");
    Ime1napomene[i]->setText(Group1Names[i]);
    }

EDIT:
This is how i take values from 1 editBox and transfer that values to another EditBox:
Code: [Select]
tgui::Panel::Ptr Group1 = gui.get("Group1"); // open Group1
    tgui::EditBox::Ptr Ime1 = Group1->get("Ime1");   // open EditBox named Ime
    sf::String Ime = Ime1->getText();    // getText from editBox named Ime

    tgui::Panel::Ptr Group1Napomene = gui.get("Group1Napomene");    // open Group1Napomene
    tgui::EditBox::Ptr Ime1napomene = Group1Napomene->get("Ime1"); // Get EditBox Ime
    Ime1napomene->setText(Ime);    // Save value from EdidBox Ime from Group1 into
           // EditBox named Ime from Group1Napomene
I want to do that with vectors becouse i have a lot of EditBoxes[/code]
« Last Edit: 24 July 2013, 17:18:31 by wmbuRn »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Did you add anything to Ime1napomene earlier (with the push_back function)? What is supposed to be in there?

I did nothing with Ime1napomene. Its fresh variable for purpose of using it for transfering values betwean EditBoxes. Didnt use push.back() function. And even with that function i still get same core dumped.

In Ime1napomene should be EditBoxes named "Ime" + tgui::to_string(i)
So i can use
Ime1napomene.setText();

But obviusly i am failing at making it to work :)
« Last Edit: 24 July 2013, 17:26:06 by wmbuRn »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
The edit in your previous post actually made it more clear to me what you are trying to achieve.

So this should be what you want:
Code: [Select]
tgui::Panel::Ptr Group1 = gui.get("Group1");
tgui::Panel::Ptr Group1Napomene = gui.get("Group1Napomene");

for (unsigned i = 0; i < 30; ++i)
{
    tgui::EditBox::Ptr Ime1 = Group1->get("Ime" + tgui::to_string(i));
    sf::String text = Ime1->getText();

    tgui::EditBox::Ptr Ime1napomene = Group1Napomene->get("Ime" + tgui::to_string(i));
    Ime1napomene->setText(text);
}

Error: /usr/local/include/TGUI/SharedWidgetPtr.hpp:271: T* tgui::SharedWidgetPtr<T>::operator->() const [with T = tgui::EditBox]: Assertion `m_WidgetPtr != __null' failed.


DBG shows line: Ime1napomene->setText(text);


Code in that EDIT is working.But it is for only 1 Editbox. I need to transfer values from 30 editboxes [with vectors] to 30 diferent EditBoxes

psuedo code:
Group1.EditBox-Ime[0] send value to > Group1Napomene.EditBox-Ime[0]
Group1.EditBox-Ime[1] send value to > Group1Napomene.EditBox-Ime[1]
...
Group1.EditBox-Ime[30] send value to > Group1Napomene.EditBox-Ime[30]
/pseudo code

This is how i took values from Group1:
Code: [Select]
for (unsigned int i = 0; i < 30; ++i)
            {
 tgui::Panel::Ptr Group1 = gui.get("Group1");
 EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i));
 Group1Names.push_back(EditBoxNames[i]->getText());
           }
And i am missing part of how to use Ime1napomene.setText(Group1Names).
« Last Edit: 24 July 2013, 17:42:49 by wmbuRn »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Group1Napomene exists, because otherwise it should give that error somewhere else, but does it have those edit boxes inside? Because this error indicates that it can't find the requested edit box in Group1Napomene.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Stuck again with transfering values from one editbox to another
« Reply #10 on: 24 July 2013, 18:06:44 »
Could you show me the code where you are creating edit boxes in Group1Napomene?

Perhaps you should just upload the whole code, so that I can look for the mistake myself.

The problem probably isn't in the lines that I posted, it lies somewhere else.
A possible problem would be that you let the edit box numbers count from 1 somewhere while in this part of code it starts from 0.

Re: Stuck again with transfering values from one editbox to another
« Reply #11 on: 24 July 2013, 18:09:34 »
Remember when you told me "Not to use for (unsigned i =1; i <= 30; ++i) ?
Well thats the problem. My Group1 EditBox Ime is (unsigned i =0; i < 30; ++i)
and Group1Napomene EditBox Ime is (unsigned i =1; i <= 30; ++i). That causes the problem. I just fixed it. Your code is working. Thank you.

 Now i have to deal with "Why program takes 34-40% CPU when i click to open Group1, and it was using 4% when on main screen and loginScreen.

Re: Stuck again with transfering values from one editbox to another
« Reply #12 on: 24 July 2013, 18:11:47 »
Yup, i was uploading code to pastebin and i noticed that mistake. Thank you for your help. I can upload entire project if you want to laught at my code :)

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Stuck again with transfering values from one editbox to another
« Reply #13 on: 24 July 2013, 18:17:29 »
Quote
Now i have to deal with "Why program takes 34-40% CPU when i click to open Group1, and it was using 4% when on main screen and loginScreen.
Does your code sleep anywhere?

You should use sf::sleep in your main loop to just sleep like 1 millisecond.

If you don't do this then your code could even take 100% of one processor. Why it would suddenly increase I don't know, but if you don't let the program rest for a moment then such things could happen.

If you already use sleep then it is indeed an issue (one that I can't explain).

Quote
I can upload entire project if you want to
Not needed. I won't spend my time looking at someone elses code unless I have a reason for it.

Re: Stuck again with transfering values from one editbox to another
« Reply #14 on: 24 July 2013, 18:41:32 »
Code: [Select]
sf::Event event;
        while (screen.pollEvent(event))
        {

            if (event.type == sf::Event::Closed)
            {
                screen.close();
            }
                sf::sleep(sf::milliseconds(10));
                gui.handleEvent(event); // pass event to all widgets

        }  // end of (screen.pollEvent(event))

It randomly goes from 20%-34%-44%. I also have
Code: [Select]
sf::RenderWindow screen(sf::VideoMode(800, 600), "Titleeee");
    screen.setFramerateLimit(30);

Nevermind i will find it and will solve it. :)

And for the code i ment as a joke, i dont want somebody to do coding for me. Its not somebody job to do that for me. Anyway Thank you for your time and help :)

EDIT:
Just noticed it that  sf::sleep(sf::milliseconds(10)); was in my screen.pollEvent(). I moved it to while screen.isOpen(). Now program tooks 30% CPU nad wont rise nor fall. Which is good. Will try to reduce that. :)
« Last Edit: 24 July 2013, 18:46:29 by wmbuRn »