PDA

View Full Version : promote to...



uygar
11th October 2007, 09:00
Dear all;
I delegated my one of my tablewidgets and QDoubleSpinBoxes in that table like MyDoubleSpinBox. Than I promoted the other spinBoxes by designer in the window and it worked. but after I promoted spinboxes in another window I saw that error


./libs/myDoubleSpinBox.h:6: error: redefinition of `class MyDoubleSpinBox'
./libs/myDoubleSpinBox.h:6: error: previous definition of `class MyDoubleSpinBox'
...
libs/main.cpp:65: confused by earlier errors, bailing out
make: *** [obj/main.o] Error 1

Why I couldn't use same delegation in different ui files and is it posible?
Here is my delegation classes

"myDoubleSpinBox.h"

#include <QtGui>

class MyDoubleSpinBox : public QDoubleSpinBox

{
public:
MyDoubleSpinBox(QWidget* parent = 0)
: QDoubleSpinBox(parent) { }

void focusOutEvent(QFocusEvent* event)
{
QDoubleSpinBox::focusOutEvent(event);
// force reformatting
setValue(value());
}
QString textFromValue(double value) const
{
// the default implementation removes group separator characters
return QLocale(QLocale::Turkish).toString(value);
}
};

and for delegation:
"proformaDelegate.cpp"


#include <QtGui>
#include "proformaDelegate.h"
#include "libs/myDoubleSpinBox.h"

ProformaDelegate::ProformaDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *ProformaDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QLocale::setDefault( QLocale( QLocale::Turkish, QLocale::Turkey ) );
MyDoubleSpinBox *editor = new MyDoubleSpinBox(parent);
editor->setMinimum(0);
editor->setMaximum(4000000000);
editor->setDecimals(2);
editor->setPrefix("");
editor->setAlignment(Qt::AlignRight);
return editor;
}
...


I mean I use MyDoubleSpinBox in "proformaDelegate.cpp" and promote in one ui file, but I couldn't promote any other ui. I tried many different ways like I tried same in same time, after one by one (promoted one then closed designer and reopened it and promoted the other ui etc.)

jpn
11th October 2007, 09:07
Try adding include guards to myDoubleSpinBox.h:


#ifndef MYDOUBLESPINBOX_H
#define MYDOUBLESPINBOX_H

...

#endif // MYDOUBLESPINBOX_H