Results 1 to 11 of 11

Thread: making a class aware of the gui

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Feb 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3

    Question Re: making a class aware of the gui

    thank you all for your answers
    unfortunatelly nothing worked....

    caseChangerClass.h
    Qt Code:
    1. #ifndef caseChangerClass_H
    2. #define caseChangerClass_H
    3.  
    4. #include "ui_caseChanger.h"
    5. #include "classA.h"
    6.  
    7. #include <QDialog>
    8. #include <QMenu>
    9.  
    10.  
    11. //class caseChangerClass : public QDialog, private Ui::mainFormCaseChanger
    12. class caseChangerClass : public QDialog, private Ui::mainFormCaseChanger
    13. {
    14. Q_OBJECT
    15.  
    16. //the constructor
    17. public:
    18. caseChangerClass(QWidget *parent = 0);
    19.  
    20.  
    21. private:
    22. typeA test;
    23.  
    24. public: void caseChangerClass::setText( QString text );
    25.  
    26. };
    27.  
    28. #endif
    To copy to clipboard, switch view to plain text mode 


    caseChangerClass.cpp
    Qt Code:
    1. #include "caseChangerClass.h"
    2.  
    3. #include <QtGui>
    4. #include <QString>
    5.  
    6. caseChangerClass::caseChangerClass(QWidget* parent):QDialog(parent),test(this)
    7. {
    8.  
    9. setupUi(this);
    10.  
    11.  
    12. }
    13.  
    14. void caseChangerClass::setText( QString text )
    15. {
    16.  
    17. textEdit->setText( text );
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    classA.h
    Qt Code:
    1. #ifndef classA_H
    2. #define classA_H
    3.  
    4. #include "caseChangerClass.h"
    5.  
    6. class caseChangerClass;
    7.  
    8. class typeA
    9. {
    10.  
    11.  
    12. //the constructor
    13. public:
    14. typeA(caseChangerClass* gui);
    15. ~typeA();
    16.  
    17. caseChangerClass* m_gui;
    18.  
    19. };
    20.  
    21. #endif
    To copy to clipboard, switch view to plain text mode 

    classA.cpp
    Qt Code:
    1. #include "classA.h"
    2.  
    3. typeA::typeA(caseChangerClass* gui);
    4. {
    5.  
    6. m_gui = gui;
    7.  
    8. //this is what i tryied to do earlier....
    9. //m_gui->textEdit->append("hi!");
    10.  
    11. gui->setText( "HI" );
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "caseChangerClass.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. caseChangerClass myApp;
    9. myApp.setWindowFlags(Qt::WindowStaysOnTopHint);
    10. myApp.show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    ui_caseChanger.h
    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading ui file 'caseChanger.ui'
    3. **
    4. ** Created: Mon 2. Apr 20:23:18 2007
    5. ** by: Qt User Interface Compiler version 4.2.2
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling ui file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_CASECHANGER_H
    11. #define UI_CASECHANGER_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QTextEdit>
    18. #include <QtGui/QWidget>
    19.  
    20. class Ui_mainFormCaseChanger
    21. {
    22. public:
    23. QTextEdit *textEdit;
    24.  
    25. void setupUi(QWidget *mainFormCaseChanger)
    26. {
    27. mainFormCaseChanger->setObjectName(QString::fromUtf8("mainFormCaseChanger"));
    28. textEdit = new QTextEdit(mainFormCaseChanger);
    29. textEdit->setObjectName(QString::fromUtf8("textEdit"));
    30. textEdit->setGeometry(QRect(80, 20, 251, 171));
    31.  
    32. retranslateUi(mainFormCaseChanger);
    33.  
    34. QSize size(444, 207);
    35. size = size.expandedTo(mainFormCaseChanger->minimumSizeHint());
    36. mainFormCaseChanger->resize(size);
    37.  
    38.  
    39. QMetaObject::connectSlotsByName(mainFormCaseChanger);
    40. } // setupUi
    41.  
    42. void retranslateUi(QWidget *mainFormCaseChanger)
    43. {
    44. mainFormCaseChanger->setWindowTitle(QApplication::translate("mainFormCaseChanger", "test", 0, QApplication::UnicodeUTF8));
    45. Q_UNUSED(mainFormCaseChanger);
    46. } // retranslateUi
    47.  
    48. };
    49.  
    50. namespace Ui {
    51. class mainFormCaseChanger: public Ui_mainFormCaseChanger {};
    52. } // namespace Ui
    53.  
    54. #endif // UI_CASECHANGER_H
    To copy to clipboard, switch view to plain text mode 

    why this doesn't work??
    Attached Files Attached Files
    Last edited by aegis; 2nd April 2007 at 18:35. Reason: updated contents

Similar Threads

  1. Replies: 2
    Last Post: 16th March 2007, 09:04
  2. ("Dynamic") Class in DLL
    By durbrak in forum Qt Programming
    Replies: 5
    Last Post: 29th January 2007, 14:43
  3. Replies: 13
    Last Post: 15th December 2006, 11:52
  4. Replies: 2
    Last Post: 4th May 2006, 19:17
  5. How to propagate from one class to another
    By mahe2310 in forum Qt Programming
    Replies: 15
    Last Post: 20th March 2006, 01:27

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.