Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Vector of Button
Vector of Button [message #49509] Wed, 21 February 2018 14:51 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I am trying to create an interface that has a list of Button, each for every user in a list: each Button has the name of the user on the Label.

What I have done so far:

Vector<Button> vbo;

...

	vbo.Clear();
	for (size_t i=0; i<userslist.size(); i++) {
		Button b;
		vbo.Add(b);
	}

	for (size_t i=0; i<userslist.size(); i++) {
			vbo[i].SetLabel(userslist[i].FULLNAME);
			Add(vbo[i].VCenterPos(500-i*40).HCenterPos(300) );
	}


But when compiling I get the following errors:
-Error C2280: attempting to reference a deleted function
-Error C2100: illegal indirection

Is it possible to have a Vector of Button? And if it is, how can I declare and use it?
Thanks,
Gio
Re: Vector of Button [message #49510 is a reply to message #49509] Wed, 21 February 2018 15:32 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Giorgio,

AFAIK you can't create a vector of buttons, since it is not moveable (not directly at least).
You can use Array instead. Their interfaces are almost identical.

Array<Button> vbo; <----

...

	vbo.Clear();
	for (size_t i=0; i<userslist.size(); i++) {
		auto& bt= vbo.Add()                    
                bt.SetLabel(userslist[i].FULLNAME);
	        Add(bt.VCenterPos(500-i*40).HCenterPos(300) );
	}



If you insist on using vector, you can use One<Button>: (See One<> in U++ docs.)

Vector<One<Button>> vbo;


Best regards,
Oblivion


Re: Vector of Button [message #49511 is a reply to message #49510] Wed, 21 February 2018 16:42 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Thanks, very useful!
Previous Topic: Protect and Web
Next Topic: How to install on raspberry
Goto Forum:
  


Current Time: Fri Mar 29 08:50:49 CET 2024

Total time taken to generate the page: 0.01626 seconds