Results 1 to 2 of 2

Thread: promote to...

  1. #1
    Join Date
    Sep 2007
    Location
    Ankara TURKEY
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8

    Question promote to...

    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

    [HTML]./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[/HTML]

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

    "myDoubleSpinBox.h"
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MyDoubleSpinBox : public QDoubleSpinBox
    4.  
    5. {
    6. public:
    7. MyDoubleSpinBox(QWidget* parent = 0)
    8. : QDoubleSpinBox(parent) { }
    9.  
    10. void focusOutEvent(QFocusEvent* event)
    11. {
    12. QDoubleSpinBox::focusOutEvent(event);
    13. // force reformatting
    14. setValue(value());
    15. }
    16. QString textFromValue(double value) const
    17. {
    18. // the default implementation removes group separator characters
    19. return QLocale(QLocale::Turkish).toString(value);
    20. }
    21. };
    To copy to clipboard, switch view to plain text mode 

    and for delegation:
    "proformaDelegate.cpp"
    Qt Code:
    1. #include <QtGui>
    2. #include "proformaDelegate.h"
    3. #include "libs/myDoubleSpinBox.h"
    4.  
    5. ProformaDelegate::ProformaDelegate(QObject *parent)
    6. : QItemDelegate(parent)
    7. {
    8. }
    9. QWidget *ProformaDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
    10. {
    11. QLocale::setDefault( QLocale( QLocale::Turkish, QLocale::Turkey ) );
    12. MyDoubleSpinBox *editor = new MyDoubleSpinBox(parent);
    13. editor->setMinimum(0);
    14. editor->setMaximum(4000000000);
    15. editor->setDecimals(2);
    16. editor->setPrefix("");
    17. editor->setAlignment(Qt::AlignRight);
    18. return editor;
    19. }
    20. ...
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: promote to...

    Try adding include guards to myDoubleSpinBox.h:
    Qt Code:
    1. #ifndef MYDOUBLESPINBOX_H
    2. #define MYDOUBLESPINBOX_H
    3.  
    4. ...
    5.  
    6. #endif // MYDOUBLESPINBOX_H
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    uygar (11th October 2007)

Similar Threads

  1. QwtPlot - promote to custom widget
    By MrGarbage in forum Qwt
    Replies: 7
    Last Post: 10th February 2011, 11:12
  2. How Could I promote Qt's Drawing performance?
    By joeshow in forum Qt Programming
    Replies: 5
    Last Post: 11th September 2007, 19:04
  3. promote the contents of a dockwidget!
    By notsonerdysunny in forum Qt Tools
    Replies: 1
    Last Post: 30th July 2007, 06:17
  4. Replies: 9
    Last Post: 8th May 2006, 15:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.