View Full Version : How to connect the ARROWS from QDoubleSpinBox to display the next ARRAYINDEX?

13th January 2010, 13:33

In QDoubleSpinBox the Arrows or singlestep() does change only the displayed value, but it doesn't select the next Entry in the Array!?!

How can i connect the up/down-Arrows to the Arrayindex? e.g. MyData[20] ...MyData[21]

greetings Astronomy

13th January 2010, 18:11
You will have to look in to the QDoubleSpinBox class code and see if the member is private or protected.
If it is only protected you can subclass and access it in your subclass.
If it is private, bad luck.
You can copy the code and re implement your own QDoubleSpinBox.

13th January 2010, 22:51
Are you looking for something like QwwTextSpinBox (http://www.wysota.eu.org/wwwidgets/doc/html/qwwtextspinbox.html)?

2nd February 2010, 15:54
thanks but QwtTextSpinBox is not the thing i need. (-:

OK i see i have to make user defined Widgets. The members of QDoublespinbox, ( singlestep(), setsinglestep() ) are public. The new Class QMyDoublespinbox i have to promote in a new class in the QtDesigner in mainwindow_ui.

it turns out that i should have done this much earlier. Until now my Program is working fine with several Arrays from my own type: CMyData. I could put these CMyData -.Arrays as members in the mentioned new class: QMyDoublespinbox, but this will be a major rework. Because the Data should be only stored at one place in the SW. (At the Arrays or the customized Widgets) And i don't think a rework a this point will be wise (-;

i'll keep u updated
greetings, Astronomy

2nd February 2010, 17:10
OK, after several Linker Errors: related to Q_OBJECT: " undefined reference to `vtable for.... ", i do the subclass thing another time (:= if i have more time for this topic *gg* ).

The best alternative solution is:
1) disable the Arrows from QDoubleSpinBox (with ButtonSymbols in QtDesigner...)
2) implement 2 toolButton's like
2a) customize the size...
3) and let the Buttons navigate through the Arrays, and the QDoubleSpinBox does only the visualisation part.

Well this is a pity, i can remember, in Microsoft Visual Foundation Classes MFC 6.0, those Widgets were already implemented about ~ 1996 (-;
greetings Astronomy

2nd February 2010, 18:41
What exactly are you trying to implement? It really seems you are overcomplicating the problem.

3rd February 2010, 12:19
Hi, i'm looking basicly for something like: QDoubleSpinBoxArray, QDoubleSpinBoxList,.., or

CListView WidgetView; // (i have this in my far memory..)
WidgetView.AddItem( double ) // add some variable with the correct type.....

In my SW, i wish to add in a loop for example:

for(int i =0; i < MyArray.Size(); i++)
WidgetView.AddItem( MyArray[i]; )

And then i want to navigate with the Arrows of the widget through the index, and not through the digits/numbers of "2340.22", for example.
It would be nice to have such a feature. Maybe i did not have found the correct or appropriate widget until now, or i have overseen the correct member function of

The Problem is:
QDoubleSpinBox has no item like
QVector <double> Data
I tried that subclass thing, but, i run into too much troubles. (of course i have to learn it someday..)

For the interested reader i did:
header file:


#include <qspinbox.h>
#include <CData.h>

class CMyDoubleSpinBox : public QDoubleSpinBox

CMyDoubleSpinBox(QWidget *parent = 0);

double singleStep() const;
void setSingleStep(double value);

CData MyData;



and the cpp file: The out commented things are from the original implementation.

#include "CMyDoubleSpinBox.h"

CMyDoubleSpinBox::CMyDoubleSpinBox(QWidget *parent ): QDoubleSpinBox(parent)

double CMyDoubleSpinBox::singleStep() const
// Q_D(const QDoubleSpinBox);

// return d->singleStep.toDouble();

void CMyDoubleSpinBox::setSingleStep(double value)
// Q_D(QDoubleSpinBox);

// if (value >= 0)
// {
// d->singleStep = value;
// d->updateEdit();
// }


regards Astronomy
Ah! and sorry for any grammatical mistakes in my English,
maybe because of that, something does not come out clear :)

3rd February 2010, 14:49
OK, The "Promote to CMyDoubleSpinBox" - Thing is now compiling and linking. Maybe a "rebuild all", did solve the linker errors? Well if i find the correct signals and slots it may be working with sub-classing CDoubleSpinBox :)

regards A.