Results 1 to 10 of 10

Thread: Few general problems

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Few general problems

    Hi. I've got some problems with my program code. Here it goes:
    ConvertDialog.h:
    Qt Code:
    1. #ifndef CONVERTDIALOG_H
    2. #define CONVERTDIALOG_H
    3.  
    4. #include "ui_ConvertDialog.h"
    5.  
    6.  
    7.  
    8. class convertDialog : public QDialog, public Ui::convertDialog
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. convertDialog(QWidget *parent = 0);
    14.  
    15. public slots:
    16.  
    17. bool settingUp();
    18.  
    19.  
    20. private:
    21.  
    22. Ui::convertDialog ui;
    23. };
    24.  
    25. #endif
    To copy to clipboard, switch view to plain text mode 
    Dialog.h
    Qt Code:
    1. #ifndef DIALOG_H
    2. #define DIALOG_H
    3.  
    4. #include "ui_dialog.h"
    5.  
    6.  
    7.  
    8. class Dialog : public QDialog, public Ui::Dialog
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. Dialog(QWidget *parent = 0);
    14.  
    15. void displayConvertDialog();
    16.  
    17.  
    18.  
    19.  
    20.  
    21. private:
    22.  
    23. Ui::Dialog ui;
    24. };
    25.  
    26. #endif
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few general problems

    Dialog.cpp
    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "Dialog.h"
    4. #include "ConvertDialog.h"
    5.  
    6.  
    7.  
    8. Dialog::Dialog(QWidget *parent)
    9. : QDialog(parent)
    10. {
    11. ui.setupUi(this);
    12.  
    13. connect(pushButton, SIGNAL(clicked()), this, SLOT(convertDialog::settingUp()));
    14.  
    15. }
    16.  
    17.  
    18. convertDialog(QWidget *parent)
    19. : QDialog(parent)
    20. {
    21. ui.setupUi(this);
    22.  
    23. }
    24.  
    25. bool convertDialog::settingUp()
    26. {
    27. if (beaufortBox->isChecked() && beaufortBox_2->isChecked())
    28. {
    29. int ret = QMessageBox::information(this, tr("Speed Units Converter"),
    30. tr("You can't convert value to the same unit"),
    31. QMessageBox::Ok | QMessageBox::Default);
    32. if (ret == QMessageBox::Ok)
    33. {
    34. return false;
    35. }
    36.  
    37. }
    38.  
    39. if (knotBox->isChecked() && knotBox_2->isChecked())
    40. {
    41. int ret = QMessageBox::information(this, tr("Speed Units Converter"),
    42. tr("You can't convert value to the same unit"),
    43. QMessageBox::Ok | QMessageBox::Default);
    44. if (ret == QMessageBox::Ok)
    45. {
    46. return false;
    47. }
    48.  
    49. }
    50.  
    51. if (mpsBox->isChecked() && mpsBox_2->isChecked())
    52. {
    53. int ret = QMessageBox::information(this, tr("Speed Units Converter"),
    54. tr("You can't convert value to the same unit"),
    55. QMessageBox::Ok | QMessageBox::Default);
    56. if (ret == QMessageBox::Ok)
    57. {
    58. return false;
    59. }
    60.  
    61. }
    62.  
    63. if (kphBox->isChecked() && kphBox_2->isChecked())
    64. {
    65. int ret = QMessageBox::information(this, tr("Speed Units Converter"),
    66. tr("You can't convert value to the same unit"),
    67. QMessageBox::Ok | QMessageBox::Default);
    68. if (ret == QMessageBox::Ok)
    69. {
    70. return false;
    71. }
    72.  
    73. }
    74.  
    75. if (mphBox->isChecked() && mphBox_2->isChecked())
    76. {
    77. int ret = QMessageBox::information(this, tr("Speed Units Converter"),
    78. tr("You can't convert value to the same unit"),
    79. QMessageBox::Ok | QMessageBox::Default);
    80. if (ret == QMessageBox::Ok)
    81. {
    82. return false;
    83. }
    84.  
    85.  
    86.  
    87. }
    88.  
    89.  
    90. if (beaufortBox->isChecked() && knotBox_2->isChecked())
    91. {
    92. convertDialog->setWindowTitle("Converting value from Beaufort to Knot");
    93. toLabel->setText("Knot(s)");
    94. Dialog::displayConvertDialog();
    95. }
    96.  
    97. if (beaufortBox->isChecked() && mpsBox_2->isChecked())
    98. {
    99. convertDialog->setWindowTitle("Converting value from Beaufort to Mps");
    100.  
    101. Dialog::displayConvertDialog();
    102. }
    103.  
    104. /...and many the same looking
    105. }
    106.  
    107. if (mphBox->isChecked() && kphBox_2->isChecked())
    108. {
    109. convertDialog->setWindowTitle("Converting value from Kph to Kph");
    110. fromLabel->setText("Mile(s) per hour it's");
    111. toLabel->setText("Kilometer(s) per hour");
    112. Dialog::displayConvertDialog();
    113. }
    114.  
    115.  
    116.  
    117. }
    118.  
    119. void Dialog::displayConvertDialog()
    120. {
    121. convertDialog dlg( this );
    122.  
    123. dlg.exec();
    124. }
    To copy to clipboard, switch view to plain text mode 

    and also ui_Dialog.h, ui_ConvertDialog.h and main.cpp which contents are obvious. Here are those problems:
    Dialog.cpp:18:error: expected ) before * token
    Dialog.cpp:18:error: expected , or ; before * token
    In bool convertDialog.h:
    beaufortBox undeclared (and the same with others e.g. knotBox)
    Dialog.cpp:99:error: expected primary expression before -> token (im reporting about it only once, I've got much errors like this)
    Dialog.cpp:94:error cannot call member function void Dialog::displayConvertDialog() without object

    When I try to solve the undeclared e.g. knotBox by calling Dialog::knotBox I reach error that undefined reference to Ui:ialog or something like this because I didn't call the same to ui part of this class. How to solve all this problems? Regards
    p.s. I had to split the text between 2 posts

  3. #3
    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: Few general problems

    Without knowing how the convertDialog class is declared we can't help you much. But generally you have syntax problems (again). You're calling a non-static method as static (again) and I suspect "convertDialog" doesn't have a constructor that takes a QWidget pointer as its argument.

  4. #4
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few general problems

    Just the result of eyeballing the code

    Line 18 of Dialog.cpp should read
    Qt Code:
    1. convertDialog::convertDialog(QWidget *parent)
    To copy to clipboard, switch view to plain text mode 

    I can't tell if you're using the "is a" multiple inheritance model, or the "has a" single inheritance model for your GUI components as the header files show both implemented.

    see http://doc.trolltech.com/4.3/designe...component.html

    If your using the "has a" implementation, you probably need to use the "ui.beaufortBox->isChecked()" form etc, assuming this is defined in your ui file - if you're using the "is a" then you don't use ui.setupUI(this), just "setupUI(this)" and so on...

    Pete

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Few general problems

    Why dont you learn c++ first ? Most of your recent problems has to do with c++.
    Well if this suggestion makes you annoyed, please ignore (which you've been doing till now). The following is just for fun.
    Qt Code:
    1. bool writeQtCode()
    2. {
    3. if(youDontKnowC++) {
    4. qWarning("Please learn c++! Or use the language you know and which also has qt bindings.");
    5. return false;
    6. }
    7. if(youDontKnowQt) {
    8. qWarning("Use qt assistant and you can also ask in qtcentre");
    9. } //yup no return ;)
    10. //continue coding
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Gopala Krishna; 13th June 2007 at 21:04. Reason: missing [code] tags
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  6. #6
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few general problems

    Really funny, but you don't know if I knew C++. Maybe I just didn't use classes so I've got problems with them? Didn't you think about it?

  7. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Few general problems

    Quote Originally Posted by Salazaar View Post
    Really funny, but you don't know if I knew C++. Maybe I just didn't use classes so I've got problems with them? Didn't you think about it?
    See, i don't want to underestimate anyone. After all even i was a c++ novice 3 yrs ago. As wysota told, you should have just used c. Lets not debate about that.
    I could see in one of your post that you had started to learn c++(i mean classes). Thats nice of you but please do read it in depth, execute sample codes and write some c++ code(not qt) until you can solve most of the syntax errors yourself.
    One more suggestion. Read this book if you can get it
    Teach yourself c++, Herbert Schildt
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  8. #8
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few general problems

    Yeah, I started learning classes in depth because I didn't look at this chapter in depth at the beginning because I just didn't used it, they weren't useful for me (yeah, I know it's stupid) but I just didn't feel the advantage that classes give. Anyway

  9. #9
    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: Few general problems

    Quote Originally Posted by Gopala Krishna View Post
    As wysota told, you should have just used c.
    I didn't say he should have used C. I said (or at least meant) that using a C++ compiler with C semantics doesn't yet mean you're programming in C++.

    One more suggestion. Read this book if you can get it
    Teach yourself c++, Herbert Schildt
    He already has a nice book for beginners in his native language. If he sticks to it (implementing some simple apps underway), he should be fine. He just has to read it and not only own it.

    @Salazaar: If you have written an application in C++ without using a single class, then it means you don't know C++, sorry... I know some Chinese words, but that doesn't yet mean I can speak Chinese (nor can I say I know the language).

    C++ is an object oriented language, whereas you were using the functional approach which is appropriate for functional languages such as C. It's like you were "flying a plane" by driving it on the ground. Sure it's possible, but that's not flying (and it's impractical).

  10. #10
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few general problems

    Quote Originally Posted by Salazaar View Post
    ...but I just didn't feel the advantage that classes give. Anyway
    So I get the feeling that my last post has fallen on stony ground...

    Pete

Similar Threads

  1. Replies: 2
    Last Post: 8th March 2007, 22:22
  2. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11
  3. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  5. problems with Opengl
    By SlawQ in forum Qt Programming
    Replies: 4
    Last Post: 12th February 2006, 22:49

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.