Results 1 to 4 of 4

Thread: QLineEdit

  1. #1
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLineEdit

    I have created a form in QT Designer: here is the file generated

    ui_testemysql3.h
    Qt Code:
    1. /********************************************************************************
    2. ** Form generated from reading ui file 'testemysql3.ui'
    3. **
    4. ** Created: Tue 19. Aug 11:41:43 2008
    5. ** by: Qt User Interface Compiler version 4.4.0
    6. **
    7. ** WARNING! All changes made in this file will be lost when recompiling ui file!
    8. ********************************************************************************/
    9.  
    10. #ifndef UI_TESTEMYSQL3_H
    11. #define UI_TESTEMYSQL3_H
    12.  
    13. #include <QtCore/QVariant>
    14. #include <QtGui/QAction>
    15. #include <QtGui/QApplication>
    16. #include <QtGui/QButtonGroup>
    17. #include <QtGui/QGridLayout>
    18. #include <QtGui/QHBoxLayout>
    19. #include <QtGui/QLabel>
    20. #include <QtGui/QLineEdit>
    21. #include <QtGui/QPushButton>
    22. #include <QtGui/QVBoxLayout>
    23. #include <QtGui/QWidget>
    24.  
    25. QT_BEGIN_NAMESPACE
    26.  
    27. class Ui_testemysql3Class
    28. {
    29. public:
    30. QGridLayout *gridLayout;
    31. QVBoxLayout *verticalLayout;
    32. QHBoxLayout *horizontalLayout;
    33. QLabel *label;
    34. QLineEdit *lineEdit;
    35. QPushButton *pushButton;
    36. QPushButton *pushButton_2;
    37.  
    38. void setupUi(QWidget *testemysql3Class)
    39. {
    40. if (testemysql3Class->objectName().isEmpty())
    41. testemysql3Class->setObjectName(QString::fromUtf8("testemysql3Class"));
    42. testemysql3Class->resize(275, 98);
    43. gridLayout = new QGridLayout(testemysql3Class);
    44. gridLayout->setSpacing(6);
    45. gridLayout->setMargin(11);
    46. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    47. verticalLayout = new QVBoxLayout();
    48. verticalLayout->setSpacing(6);
    49. verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    50. horizontalLayout = new QHBoxLayout();
    51. horizontalLayout->setSpacing(6);
    52. horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    53. label = new QLabel(testemysql3Class);
    54. label->setObjectName(QString::fromUtf8("label"));
    55.  
    56. horizontalLayout->addWidget(label);
    57.  
    58. lineEdit = new QLineEdit(testemysql3Class);
    59. lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    60.  
    61. horizontalLayout->addWidget(lineEdit);
    62.  
    63. pushButton = new QPushButton(testemysql3Class);
    64. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    65.  
    66. horizontalLayout->addWidget(pushButton);
    67.  
    68.  
    69. verticalLayout->addLayout(horizontalLayout);
    70.  
    71. pushButton_2 = new QPushButton(testemysql3Class);
    72. pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
    73.  
    74. verticalLayout->addWidget(pushButton_2);
    75.  
    76.  
    77. gridLayout->addLayout(verticalLayout, 0, 0, 1, 1);
    78.  
    79.  
    80. retranslateUi(testemysql3Class);
    81.  
    82. QMetaObject::connectSlotsByName(testemysql3Class);
    83. } // setupUi
    84.  
    85. void retranslateUi(QWidget *testemysql3Class)
    86. {
    87. testemysql3Class->setWindowTitle(QApplication::translate("testemysql3Class", "testemysql3", 0, QApplication::UnicodeUTF8));
    88. label->setText(QApplication::translate("testemysql3Class", "Teste", 0, QApplication::UnicodeUTF8));
    89. pushButton->setText(QApplication::translate("testemysql3Class", "PushButton", 0, QApplication::UnicodeUTF8));
    90. pushButton_2->setText(QApplication::translate("testemysql3Class", "Close", 0, QApplication::UnicodeUTF8));
    91. Q_UNUSED(testemysql3Class);
    92. } // retranslateUi
    93.  
    94. };
    95.  
    96. namespace Ui {
    97. class testemysql3Class: public Ui_testemysql3Class {};
    98. } // namespace Ui
    99.  
    100. QT_END_NAMESPACE
    101.  
    102. #endif // UI_TESTEMYSQL3_H
    To copy to clipboard, switch view to plain text mode 

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

    testemysql3.h
    Qt Code:
    1. #ifndef TESTEMYSQL3_H
    2. #define TESTEMYSQL3_H
    3.  
    4. #include <QtGui/QWidget>
    5. #include "ui_testemysql3.h"
    6.  
    7. class QLineEdit;
    8.  
    9. class testemysql3 : public QWidget
    10. {
    11. Q_OBJECT
    12.  
    13. public:
    14. testemysql3(QWidget *parent = 0, Qt::WFlags flags = 0);
    15. ~testemysql3();
    16.  
    17. private:
    18. Ui::testemysql3Class ui;
    19.  
    20. private slots:
    21. void on_pushButton_clicked();
    22. void on_pushButton_2_clicked();
    23. };
    24.  
    25. #endif // TESTEMYSQL3_H
    To copy to clipboard, switch view to plain text mode 

    testemysql3.cpp

    Qt Code:
    1. #include "testemysql3.h"
    2. #include <QApplication>
    3. #include <QLineEdit>
    4.  
    5. testemysql3::testemysql3(QWidget *parent, Qt::WFlags flags)
    6. : QWidget(parent, flags)
    7. {
    8. ui.setupUi(this);
    9. }
    10.  
    11. testemysql3::~testemysql3()
    12. {
    13.  
    14. }
    15.  
    16.  
    17. void testemysql3::on_pushButton_2_clicked()
    18. {
    19. close();
    20. }
    21.  
    22. void testemysql3::on_pushButton_clicked()
    23. {
    24. lineEdit->setText("Olha o Texto");
    25. }
    To copy to clipboard, switch view to plain text mode 

    When I try to compile I got this error:

    ------ Build started: Project: testemysql3, Configuration: Debug Win32 ------
    Moc'ing testemysql3.h...
    Compiling...
    moc_testemysql3.cpp
    testemysql3.cpp
    .\testemysql3.cpp(26) : error C2065: 'lineEdit' : undeclared identifier
    .\testemysql3.cpp(26) : error C2227: left of '->setText' must point to class/struct/union/generic type
    type is ''unknown-type''
    main.cpp
    Generating Code...
    Build log was saved at "file://c:\Documents and Settings\Renan\Meus documentos\Visual Studio 2005\Projects\testemysql3\testemysql3\Debug\BuildL og.htm"
    testemysql3 - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Whats wrong?

    Renan

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit

    did you add ui file to .pro file?

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLineEdit

    sorry, try this
    Qt Code:
    1. ui.lineEdit->setText(...);
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to spirit for this useful post:

    GuL (19th August 2008)

  5. #4
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit

    spirit

    thank you

    That was the problem from the other post QSqlQuery and QLineEdit

    the "ui." was why I cannot get the result from a query.

    Thanks a lot,

    Renan

Similar Threads

  1. how to force QLineEdit not null ?
    By lovelypp in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 09:26
  2. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 09:05
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  4. how to get last character of QLineEdit
    By yagabey in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2008, 16:38
  5. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25

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.