PDA

View Full Version : input widget for vectors (e.g. double v[6]) - howto do?



KlausKoe
14th June 2010, 10:56
Hi,

in my program I have to maintain 4 vectors of length 8. The length might vary a little in future.

I don't want to add every vector component manually to the UI. So my question is if there is an easy way to create an own input widget for this?

rgds
kk

wysota
14th June 2010, 12:14
You can create your own custom widget composed from spinboxes or whatever else you want and add instances of that widget to your form either though widget promotion or a custom widget plugin for Designer.

SneakyPeterson
14th June 2010, 13:06
kk,

Could you give us a little bit more insight into what you're trying to accomplish? Are you asking if there's a widget that can act as a button to add vectors to your UI, to modify the length of the widgets, or something else entirely. Right now the only answer I can give you to your questions is "yes, probably" without getting a better idea of what you're trying to do.

Cheers,
sp

KlausKoe
14th June 2010, 13:22
Hi SP,

>Are you asking if there's a widget that can act as a button to add vectors to your UI
That doesn't sound like my idea.

I want to create a UI for an algorithm which needs 4 double[8] vectors [or call it array] as input parameters. I hope there's any easy way that I only have one mainWidget per vector which maybe looks like 8 lineedits (subWidgets) side by side. On the UI I would only add the mainWidgets and set the width and number of subewidgets (vector length). Maybe that's not too complicated, but I just started with QT and I always had my issues with UI programming.

I hope I could clarifiy it a little.

Zlatomir
14th June 2010, 16:01
It is hard for us to respond to your question, because you can use a lot of methods to achieve that (and might depend on other stuff, like: how/where you store your vector, etc)

You can use:
1) spinbox (QDoubleSpinBox most likely because you want double), here you can choose a widget with: one label, one spinbox, and one submit button (and of-course an algorithm to repeat the actions for each element)
2) a spinbox for each element
3) a line edit for each vector (with double values separated by comma, or space or what you like)
4) a textedit (you can use new-line for vector delimitation, and comma or space for values)
5) derive a class from QTableWidget (and make an excel-like program), if you need more computation on the values
... i'm sure that there are a lot more ways to achieve this, imagination is the limit

Think as you are the user... so i ask you: How would you like to enter the input in this application?