Results 1 to 19 of 19

Thread: Text box and list box connectivity

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2006
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Text box and list box connectivity

    i have zipped the sample.h file as u had asked..i have attached sample.cpp also along with that
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Text box and list box connectivity

    ok here it is

    Qt Code:
    1. class Ui_Dialog : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. QWidget *layoutWidget;
    7. QHBoxLayout *hboxLayout;
    8. QPushButton *exit;
    9. QTextEdit *text2;
    10. QListWidget *list1;
    11. QPushButton *enter;
    12. QTextEdit *text1;
    13.  
    14. void setupUi(QDialog *Dialog)
    15. {
    16. Dialog->setObjectName(QString::fromUtf8("Dialog"));
    17. Dialog->resize(QSize(552, 555).expandedTo(Dialog->minimumSizeHint()));
    18. layoutWidget = new QWidget(Dialog);
    19. layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
    20. layoutWidget->setGeometry(QRect(230, 410, 131, 38));
    21. hboxLayout = new QHBoxLayout(layoutWidget);
    22. hboxLayout->setSpacing(6);
    23. hboxLayout->setMargin(0);
    24. hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
    25. exit = new QPushButton(layoutWidget);
    26. exit->setObjectName(QString::fromUtf8("exit"));
    27.  
    28. hboxLayout->addWidget(exit);
    29.  
    30. text2 = new QTextEdit(Dialog);
    31. text2->setObjectName(QString::fromUtf8("text2"));
    32. text2->setGeometry(QRect(60, 220, 104, 52));
    33. list1 = new QListWidget(Dialog);
    34. list1->setObjectName(QString::fromUtf8("list1"));
    35. list1->setGeometry(QRect(380, 90, 120, 80));
    36. enter = new QPushButton(Dialog);
    37. enter->setObjectName(QString::fromUtf8("enter"));
    38. enter->setGeometry(QRect(210, 90, 108, 36));
    39. text1 = new QTextEdit(Dialog);
    40. text1->setObjectName(QString::fromUtf8("text1"));
    41. text1->setGeometry(QRect(60, 80, 104, 52));
    42. QWidget::setTabOrder(text1, enter);
    43. QWidget::setTabOrder(enter, list1);
    44. QWidget::setTabOrder(list1, text2);
    45. QWidget::setTabOrder(text2, exit);
    46. retranslateUi(Dialog);
    47. QObject::connect(exit, SIGNAL(clicked()), this, SLOT(reject()));
    48. QObject::connect(enter, SIGNAL(clicked()), this, SLOT(show()));
    49. QObject::connect(list1, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(copy()));
    50. QObject::connect(text1, SIGNAL(textChanged()), this, SLOT(update()));
    51.  
    52. QMetaObject::connectSlotsByName(Dialog);
    53. } // setupUi
    54.  
    55. void retranslateUi(QDialog *Dialog)
    56. {
    57. Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
    58. exit->setText(QApplication::translate("Dialog", "Exit", 0, QApplication::UnicodeUTF8));
    59. enter->setText(QApplication::translate("Dialog", "Enter", 0, QApplication::UnicodeUTF8));
    60. Q_UNUSED(Dialog);
    61. } // retranslateUi
    62.  
    63. public slots:
    64.  
    65. void show()
    66. {
    67. list1->addItem(text1->toPlainText());
    68. }
    69.  
    70.  
    71. };
    To copy to clipboard, switch view to plain text mode 

    But I would not suggest you to do this way. Please look into Qt examples as on how the classes are designed.

  3. #3
    Join Date
    Jul 2006
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Text box and list box connectivity

    its not working .. please say me
    1)the code to copy all the characters from the text box to list box when a push button like enter is being clicked after entering all the characters in the text box....... is not working

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Text box and list box connectivity

    I have tested this and it works perfectly for me. When I click on the enter button the text gets copied to the list1.

    Ofcourse u'll need to add

    #include<QObject> in the beginning

    and

    namespace Ui {
    class Dialog: public Ui_Dialog {};
    } // namespace Ui


    at the end

  5. The following user says thank you to munna for this useful post:

    :db:sStrong (25th July 2006)

  6. #5
    Join Date
    Jul 2006
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Text box and list box connectivity

    on executing "make" command i'm getting the follwoing errors..
    wat 2 do?

    MyDialog.cpp: In member function `void MyDialog::copy()':
    MyDialog.cpp:16: error: `addItem' undeclared (first use this function)
    MyDialog.cpp:16: error: (Each undeclared identifier is reported only once for
    each function it appears in.)
    make: *** [MyDialog.o] Error 1

  7. #6
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Text box and list box connectivity

    We can't solve problems by using the same kind of thinking we used when we created them

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.