PDA

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



Astronomy
13th January 2010, 13:33
Hi!

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

high_flyer
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.

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

Astronomy
2nd February 2010, 15:54
Hi,
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.
like:
http://books.google.at/books?id=T373zcyFfvoC&pg=PA164&lpg=PA164&dq=promoted+class&source=bl&ots=W9uv0eE27L&sig=aFDKg8QExBFJQ0lBPZ9Yj_V7x2A&hl=de&ei=BjVoS9-7JZDkmwPJmbWuBg&sa=X&oi=book_result&ct=result&resnum=8&ved=0CCsQ6AEwBw#v=onepage&q=promoted%20class&f=false

Hmmm...
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

Astronomy
2nd February 2010, 17:10
Hahahahaha
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
ui->toolButtonWavelengthUp->setArrowType(Qt::UpArrow);
ui->toolButtonWavelengthDown->setArrowType(Qt::DownArrow);
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

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

Astronomy
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
http://doc.trolltech.com/4.5/qdoublespinbox-members.html

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:



#ifndef CMYDOUBLESPINBOX_H
#define CMYDOUBLESPINBOX_H


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

class CMyDoubleSpinBox : public QDoubleSpinBox
{
Q_OBJECT

public:
CMyDoubleSpinBox(QWidget *parent = 0);

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

CData MyData;

};

#endif // CMYDOUBLESPINBOX_H

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 :)

Astronomy
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.