Results 1 to 14 of 14

Thread: no appropriate default constructor available

  1. #1
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default no appropriate default constructor available

    hi all,
    i'm trying to compile my project, that i have made under linux, in windows
    graphForm::graphForm(QWidget *parent) :
    QMdiSubWindow(parent),
    ui(new Ui::graphForm)
    in the code with red color i get the following error, although i have no problems in liunx

    Fehler:C2512: 'Ui::graphForm' : no appropriate default constructor available
    does onybody know what could that be

    any help will be apreciated

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: no appropriate default constructor available

    Did uic create the Ui::graphForm class for you?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: no appropriate default constructor available

    yes it is created with qt creator

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: no appropriate default constructor available

    I think wysota meant the automatically generated class code, created by uic from the form .ui file ( form.ui should give you ui_form.h ).

  5. #5
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: no appropriate default constructor available

    yes it does.
    i have forgetten to say that i'm trying to compile a project under windows, witch was developed under linux, under linux there is no problems.

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: no appropriate default constructor available

    Can you post the content of this header ?

  7. #7
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: no appropriate default constructor available

    Qt Code:
    1. #include "graphform.h"
    2. #include "ui_graphform.h"
    3. #include "messwertemodel.h"
    4. #include <qwt_plot_curve.h>
    5. #include <qwt_symbol.h>
    6. #include <QDebug>
    7. #include <qwt_plot_grid.h>
    8. #include <QStyledItemDelegate>
    9.  
    10.  
    11. graphForm::graphForm(QWidget *parent) :
    12. QMdiSubWindow(parent), ui(new Ui::graphForm)
    13. {
    14. ui->setupUi(this);
    15. this->model=new messwerteModel();
    16. this->ui->messwerteTableView->setModel(this->model);
    17. this->ui->messwertQwtPlot->axisAutoScale(false);
    18. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: no appropriate default constructor available

    I've meant the automatically generated header: "ui_graphform.h"

  9. #9
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: no appropriate default constructor available

    hear it is
    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading UI file 'graphform.ui'
    3. **
    4. ** Created:
    5. ** by: Qt User Interface Compiler version 4.7.2
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling UI file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_GRAPHFORM_H
    11. #define UI_GRAPHFORM_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QFrame>
    18. #include <QtGui/QGridLayout>
    19. #include <QtGui/QHBoxLayout>
    20. #include <QtGui/QHeaderView>
    21. #include <QtGui/QLabel>
    22. #include <QtGui/QLineEdit>
    23. #include <QtGui/QPushButton>
    24. #include <QtGui/QRadioButton>
    25. #include <QtGui/QScrollArea>
    26. #include <QtGui/QTabWidget>
    27. #include <QtGui/QTableView>
    28. #include <QtGui/QWidget>
    29. #include "qwt_plot.h"
    30. #include "qwt_text_label.h"
    31.  
    32. QT_BEGIN_NAMESPACE
    33.  
    34. class Ui_graphForm
    35. {
    36. public:
    37.  
    38.  
    39.  
    40.  
    41. QwtPlot *messwertQwtPlot;
    42.  
    43. void setupUi(QWidget *graphForm)
    44. {
    45. if (graphForm->objectName().isEmpty())
    46. graphForm->setObjectName(QString::fromUtf8("graphForm"));
    47. graphForm->resize(842, 602);
    48. QIcon icon;
    49. icon.addFile(QString::fromUtf8("icons/newGraph.png"), QSize(), QIcon::Normal, QIcon::Off);
    50. graphForm->setWindowIcon(icon);
    51. horizontalLayoutWidget = new QWidget(graphForm);
    52. horizontalLayoutWidget->setObjectName(QString::fromUtf8("horizontalLayoutWidget"));
    53. horizontalLayoutWidget->setGeometry(QRect(10, 30, 831, 321));
    54. horizontalLayout = new QHBoxLayout(horizontalLayoutWidget);
    55. horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    56. horizontalLayout->setContentsMargins(0, 0, 0, 0);
    57. tabWidget_2 = new QTabWidget(graphForm);
    58. tabWidget_2->setObjectName(QString::fromUtf8("tabWidget_2"));
    59. tabWidget_2->setGeometry(QRect(4, 350, 791, 251));
    60. tab_3 = new QWidget();
    61. tab_3->setObjectName(QString::fromUtf8("tab_3"));
    62. scrollArea = new QScrollArea(tab_3);
    63. scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    64. scrollArea->setGeometry(QRect(0, 10, 631, 214));
    65. scrollArea->setWidgetResizable(true);
    66. scrollAreaWidgetContents = new QWidget();
    67. scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
    68. scrollAreaWidgetContents->setGeometry(QRect(0, 0, 627, 210));
    69. gridLayout = new QGridLayout(scrollAreaWidgetContents);
    70. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    71. messwerteTableView = new QTableView(scrollAreaWidgetContents);
    72. messwerteTableView->setObjectName(QString::fromUtf8("messwerteTableView"));
    73. messwerteTableView->setMouseTracking(true);
    74.  
    75. gridLayout->addWidget(messwerteTableView, 0, 1, 1, 1);
    76.  
    77. scrollArea->setWidget(scrollAreaWidgetContents);
    78. addMesswertButton = new QPushButton(tab_3);
    79. addMesswertButton->setObjectName(QString::fromUtf8("addMesswertButton"));
    80. addMesswertButton->setGeometry(QRect(680, 10, 41, 27));
    81. QIcon icon1;
    82. icon1.addFile(QString::fromUtf8("icons/plus.png"), QSize(), QIcon::Normal, QIcon::Off);
    83. addMesswertButton->setIcon(icon1);
    84. deleteMesswertButton = new QPushButton(tab_3);
    85. deleteMesswertButton->setObjectName(QString::fromUtf8("deleteMesswertButton"));
    86. deleteMesswertButton->setGeometry(QRect(680, 46, 41, 27));
    87. QIcon icon2;
    88. icon2.addFile(QString::fromUtf8("icons/minus.png"), QSize(), QIcon::Normal, QIcon::Off);
    89. deleteMesswertButton->setIcon(icon2);
    90. linearFrame->setFrameShadow(QFrame::Raised);
    91.  
    92. aValEdit->setObjectName(QString::fromUtf8("aValEdit"));
    93. aValEdit->setGeometry(QRect(24, 3, 41, 25));
    94. bVarLbl = new QLabel(linearFrame);
    95. bVarLbl->setObjectName(QString::fromUtf8("bVarLbl"));
    96. bVarLbl->setGeometry(QRect(78, 3, 16, 17));
    97.  
    98.  
    99. line->setAutoFillBackground(false);
    100. line->setFrameShadow(QFrame::Raised);
    101. line->setLineWidth(8);
    102. pbtnPrint->setIcon(icon3);
    103. pbtnPrint->setIconSize(QSize(32, 32));
    104. pbtnExport = new QPushButton(graphForm);
    105. pbtnExport->setObjectName(QString::fromUtf8("pbtnExport"));
    106. pbtnExport->setGeometry(QRect(806, 500, 30, 31));
    107. QIcon icon4;
    108. icon4.addFile(QString::fromUtf8("icons/pdf.png"), QSize(), QIcon::Normal, QIcon::Off);
    109. pbtnExport->setIcon(icon4);
    110. pbtnExport->setIconSize(QSize(24, 24));
    111. messwertQwtPlot = new QwtPlot(graphForm);
    112. messwertQwtPlot->setObjectName(QString::fromUtf8("messwertQwtPlot"));
    113. messwertQwtPlot->setGeometry(QRect(8, 30, 821, 319));
    114. QWidget::setTabOrder(lineareFunkRadio, aValEdit);
    115. QWidget::setTabOrder(aValEdit, bValEdit);
    116. QWidget::setTabOrder(bValEdit, logFunkRadio);
    117. QWidget::setTabOrder(logFunkRadio, logVarEdit);
    118. QWidget::setTabOrder(logVarEdit, exponentialFunkRadio);
    119. QWidget::setTabOrder(exponentialFunkRadio, exponentialVarEdit);
    120. QWidget::setTabOrder(exponentialVarEdit, sinusFunkRadio);
    121. QWidget::setTabOrder(sinusFunkRadio, sinusAVarEdit);
    122. QWidget::setTabOrder(sinusAVarEdit, quadratischFunkRadio);
    123. QWidget::setTabOrder(quadratischFunkRadio, quadratischVarEdit);
    124. QWidget::setTabOrder(quadratischVarEdit, clearAllButton);
    125. QWidget::setTabOrder(clearAllButton, scrollArea);
    126. QWidget::setTabOrder(scrollArea, drowTXButton);
    127. QWidget::setTabOrder(drowTXButton, drowTYButton);
    128. QWidget::setTabOrder(drowTYButton, drowTYXButton);
    129. QWidget::setTabOrder(drowTYXButton, drowTXYButton);
    130. QWidget::setTabOrder(drowTXYButton, addMesswertButton);
    131. QWidget::setTabOrder(addMesswertButton, deleteMesswertButton);
    132. QWidget::setTabOrder(deleteMesswertButton, messwerteTableView);
    133. QWidget::setTabOrder(messwerteTableView, konstanteFunButton);
    134. QWidget::setTabOrder(konstanteFunButton, ausgleichFunButton);
    135. QWidget::setTabOrder(ausgleichFunButton, tabWidget_2);
    136.  
    137. retranslateUi(graphForm);
    138. QObject::connect(ausgleichFunButton, SIGNAL(clicked()), graphForm, SLOT(ausgleischFun()));
    139. QObject::connect(exponentialVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(exponentialeFun()));
    140. QObject::connect(konstanteFunButton, SIGNAL(clicked()), graphForm, SLOT(konstanteFun()));
    141. QObject::connect(bValEdit, SIGNAL(editingFinished()), graphForm, SLOT(lineareFun()));
    142. QObject::connect(logVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(logFun()));
    143. QObject::connect(sinusAVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(sinusFun()));
    144. QObject::connect(clearAllButton, SIGNAL(clicked()), graphForm, SLOT(clearAll()));
    145. QObject::connect(graphForm, SIGNAL(destroyed()), graphForm, SLOT(formDestroyed()));
    146. QObject::connect(addMesswertButton, SIGNAL(clicked()), graphForm, SLOT(addMesswert()));
    147. QObject::connect(deleteMesswertButton, SIGNAL(clicked()), graphForm, SLOT(deleteMesswert()));
    148. QObject::connect(drowTXButton, SIGNAL(clicked()), graphForm, SLOT(drowTX()));
    149. QObject::connect(drowTYXButton, SIGNAL(clicked()), graphForm, SLOT(drowTYX()));
    150. QObject::connect(drowTYButton, SIGNAL(clicked()), graphForm, SLOT(drowTY()));
    151. QObject::connect(lineareFunkRadio, SIGNAL(clicked()), graphForm, SLOT(linearVarvisible()));
    152. QObject::connect(logFunkRadio, SIGNAL(clicked()), graphForm, SLOT(logVarVisible()));
    153. QObject::connect(exponentialFunkRadio, SIGNAL(clicked()), graphForm, SLOT(exponetialVarVisible()));
    154. QObject::connect(sinusFunkRadio, SIGNAL(clicked()), graphForm, SLOT(sinusVarVisible()));
    155. QObject::connect(quadratischFunkRadio, SIGNAL(clicked()), graphForm, SLOT(quadratischeVarvisible()));
    156. QObject::connect(pbtnPrint, SIGNAL(clicked()), graphForm, SLOT(print()));
    157. QObject::connect(pbtnExport, SIGNAL(clicked()), graphForm, SLOT(exportInPdf()));
    158.  
    159. tabWidget_2->setCurrentIndex(1);
    160.  
    161.  
    162. QMetaObject::connectSlotsByName(graphForm);
    163. } // setupUi
    164.  
    165.  
    166. };
    167.  
    168. namespace Ui {
    169. class graphForm: public Ui_graphForm {};
    170. } // namespace Ui
    171.  
    172. QT_END_NAMESPACE
    173.  
    174. #endif // UI_GRAPHFORM_H
    To copy to clipboard, switch view to plain text mode 

    i have shortened the code
    Last edited by yazan; 19th June 2011 at 19:50. Reason: updated contents

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: no appropriate default constructor available

    What about the part you cut out? Is there a constructor for the class?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: no appropriate default constructor available

    no there is no constructor.
    should not qt be portable. as i have seen one must change his code to get it compiled in win (in my case). i have solved another problem, witch i didn't have in linux.
    Last edited by yazan; 19th June 2011 at 20:26. Reason: updated contents

  12. #12
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: no appropriate default constructor available

    How is the member variable ui declared ? You have some kind of forward declaration? Can you post the content of graphform.h ?

  13. #13
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: no appropriate default constructor available

    Are you using the same version of Qt/Creator on both systems?

    Are you attempting to use automatically generated files created on Linux under Windows?

    Have you done a complete 'make clean' of your project and regenerated everything from scratch?

    Are you sure this code compiled under Linux? 'cause it doesn't look like it should; there's no constructor corresponding to the object you're trying to construct in the initialization routine.

    To answer the question you've repeated several times now: yes, Qt code is, for the most part, portable without change between Linux and Windows. The only exceptions are sections of code that are clearly platform-dependent such as calls to Windows or Linux OS routines or similar resources. I've ported several large programs between the two systems and have never once had to rewrite code.
    Last edited by SixDegrees; 19th June 2011 at 20:47.

  14. #14
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: no appropriate default constructor available

    But I think there is a default, auto-generated no-argument constructor like for any other C++ class without other constructors, so new Ui::graphForm should be ok.
    I agree with SixDegrees, you should rebuild everything from scratch.

Similar Threads

  1. Help with QSettings default constructor
    By Polnareff in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2010, 18:27
  2. QtScript: default constructor question
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 19:36
  3. Replies: 6
    Last Post: 8th July 2009, 20:28
  4. Q3Frame : no appropraite default constructor available
    By Project25 in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2007, 23:23
  5. What default constructor?
    By bitChanger in forum General Programming
    Replies: 5
    Last Post: 15th February 2006, 19:50

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.