Widget not updating, Signals and Slots
-
I have two widgets that are each in there own class. I want to send a string from one widget to the other. I am using signals and slots to do this. However, the widget does not update. I know the signals and slots are working as intended because I have a qDebug() line that prints out everytime the slot the called. Is there something in Qt that can block a widget from updating??? This makes no sense to me.
@
messagelogcommand.h:
class MessageLogCommand : public QWidget
{
Q_OBJECTpublic:
explicit MessageLogCommand(QWidget *parent = 0);QPlainTextEdit *messageLog;
public Q_SLOTS:
void updateWidgets(const QString &text)
{
messageLog->appendPlainText(text);
}homeCommand.h:
class homeCommand : public QWidget
{
Q_OBJECTpublic:
explicit homeCommand(QWidget *parent = 0);
Q_SIGNALS:
void textChanged(const QString &text);homeCommand.cpp
Q_EMIT textChanged("OMG");main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;w.show(); MessageLogCommand s; homeCommand m; QObject::connect(&m, SIGNAL(textChanged(QString)), &s, SLOT(updateWidgets(QString))); return a.exec();
}@
-
Hi,
Without any code it will be difficult to help you. Can you share at least the slot implementation ?
-
You'll need to show us how you try to update the widget.
-
Thanks for the minimal code; that does make your issue easier to understand. One more request: Please add '@' before and after your code to format it for readability. :)
Some questions:
Did you make the connection before emitting your signal?
Did you put qDebug() inside updateWidgets()? What does it show?
Did you instantiate messageLog before emitting your signal?
Is your QPlainTextEdit visible?
Do you see any error/warning messages when running your app?
-
[quote author="JKSH" date="1390578493"]Thanks for the minimal code; that does make your issue easier to understand. One more request: Please add '@' before and after your code to format it for readability. :)
Some questions:
Did you make the connection before emitting your signal?
Did you put qDebug() inside updateWidgets()? What does it show?
Did you instantiate messageLog before emitting your signal?
Is your QPlainTextEdit visible?
Do you see any error/warning messages when running your app?[/quote]
- Yes, I also emit the signal every second indefinitely
- Yes, and yes it does show
- Yes
- Yes, it is visible, if I update the widget from the slot that is triggered once a second from that class the widget updates
- No, no errors or warnings
-
then can you show homeCommand.cpp ?