0

I've got a question about signals and slots. In my app, I want to connect a signal from one object to a textEdit in a dialog window. My signal emits a QString; if I violate encapsulation (by making the UI public instead of private) and connect the signal directly to the textEdit it works. But I feel that it's not the right way. If I make something like the following:

connect(m_osgWidget->picker.get(), SIGNAL(setX(QString)), m_addAgentDlg, SLOT(getX(QString))); 

where:

void getX(QString) { this->ui.textEdit(QString); } 

It gives me an error that I can't use QString in this this->ui.textEdit(QString); I need the QString from setX() signal pasted into the textEdit of m_addAgentDlg. How this can be done? Where did I make a mistake?

1 Answer 1

2

I am sorry to say this, but you need to learn basic C++. The proper syntax is this for such things in C++ with Qt:

connect(m_osgWidget->picker.get(), SIGNAL(setX(const QString&)), m_addAgentDlg, SLOT(getX(const QString&))); // Why do you call it getX? Should it be called setText instead? void getX(const QString& string) { ui->textEdit->setText(string); } 
Sign up to request clarification or add additional context in comments.

2 Comments

Well, i still learn so it's not necessary to say. I have tried every possible type of code posted above, including one that you provided. It doesn't work. Thats why i ask it here. I continue get messages that there is no such slot in object.
@AzraithSherkhan: you have to rerun qmake, but please buy a C++ book. It is necessary to say as these situations are why the authors spent their lives with them.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.