0

I have made the ui using QT designer. Which has a textbox in main window in which user enters his name. i want to call function 'input' when the data entered by user is over. but i cant find a way to link a textbox from ui designed using QT designer to a coded function form other class. I guess signal and slots (in qt designer) can only link to components of the same window.

Again, at the same time i want to store the name entered by the user in a char variable usr_nm[] in the same function input. I later want to display the name in a text browser with some other details in function output.(-->Input and output function are in same class.)

Abhishek Verma
  • 366
  • 2
  • 13

1 Answers1

0

Do you have to define this in Qt Designer?

It seems to me it would be better if you simply used an auto-connection slot, for example:

on_textBoxName_textChanged()  // I'm assuming you are using QTextEdit
{
     ui->textBoxName->toPlainText();  // this returns text in QTextEdit as QString.  
}

This uses auto-connection - see here.

MarPan
  • 126
  • 1
  • 2
  • where should i write this? also isn't there a method to do that directly from qt designer. – Abhishek Verma Jan 08 '13 at 06:20
  • This should be added to the *.hpp and *.cpp files associated with the *.ui file. Qt-designer allows you only to connect existing signals and slots, and since you want to do more, I don't see a way to do it in designer. (Qt4 designer doesn't support custom slots, as answered [here](http://stackoverflow.com/questions/165637/how-do-i-create-a-custom-slot-in-qt4-designer) ) – MarPan Jan 10 '13 at 11:24