Signals and slots or whatever
-
@jrod2much said in Signals and slots or whatever:
What should be my next step?
Make the interpreter a QObject if it's not already and declare a signal identical to the one in CccModule.
Now wherever the interpreter creates the CccModuleconnect()
the 2 signals togetherThe following step is finding out how interpreter gets created (by MainWindow?) it might be tricky as it's in a secondary thread but try and have a look
-
@VRonin Alright so I found different data to connect to the textBrowser, and after many attempts and much research, I am still unable to do it. Here are update images:
I don't know the coding lingo, but I' think I found the creation of the render class object or whatever. It is in this Interpret class that is then made an object in the mainwindow
I am showing you any pieces of code that could possibly be related to what I am trying to do. Unfortunately, there are no examples, tutorials, or explanations on how to connect to a textBrowser, no matter where I search on the internet. Most tutorials about connections lazily explain elementary connections between buttons and sliders that are preformatted anyway. I would like to give it one more try before changing my direction from the possibilty of a UI that can display data values to just using printf functions and continuing my project. If you see any way you can help me, I would greatly appreciate it.
-
@jrod2much said in Signals and slots or whatever:
Most tutorials about connections lazily explain elementary connections
connect() always work the same way no matter what you're connecting to what. You can't expect tutorials for everything.
What is the problem now?
It doesn't compile?
Are your slots in "slots" section and signals in "signals" section in your classes? Are those classes derived from QObject? -
@jsulm Yes connect() always works the same but what I mean by lazy tutorials is that many of the tutorials show how to use preformatted connect()'s. In my case, I have create every aspect of the connection. I don't know what goes in the four arguments of the connect and when I try to use the m_render for the first argument, it does not recognize.
-
@jrod2much said in Signals and slots or whatever:
preformatted connect()
What is this?
As I said: it is always the same.
connect(senderObject, signal, receiverObject, slot);
There is really nothing special.
Is Renderer derived from QObject?
Is m_renderer a pointer?
Can you please post the error message you get? -
@jrod2much You still did not answer my question: is Renderer derived from QObject? Did you include the header file containing Renderer class definition?
-
@jsulm said in Signals and slots or whatever:
@jrod2much You still did not answer my question: is Renderer derived from QObject? Did you include the header file containing Renderer class definition?
Should I do that?
Update: I included it, now the program runs. However, It is not printing any text on the textBrowser, but atleast I am getting somewhere
-
@VRonin So I have changed where I am trying to get the value from, it is actually from the Renderer class, not the CccModule class anymore.
New error
QObject::connect: Cannot connect (null)::Rvalues(QString) to QTextBrowser::setText(QString)
-
@jrod2much said in Signals and slots or whatever:
So I have changed where I am trying to get the value from
I see, cool
New error
Could you use Qt5 connection instead? errors usually are a lot more helpful:
connect(m_interpreter->m_renderer,&Renderer::Rvalues,m_ui->textBrowser,&QTextBrowser::setText);
-
15:51:34: Debugging starts
(Internal error: pc 0x0 in read in psymtab, but not in symtab.)
(Internal error: pc 0x0 in read in psymtab, but not in symtab.)@VRonin said in Signals and slots or whatever:
If you remove the connect you get no such error, correct?
UPDATE: correct
-
@jrod2much said in Signals and slots or whatever:
QObject::connect: Cannot connect (null)::Rvalues(QString) to QTextBrowser::setText(QString)
You're using a nullptr to connect, this can't work. The sender object was not created.
-
@jsulm Is this what you are talking about:
#include "console.h" #include "interpreter.h" #include "chirpmon.h" #include "dfu.h" #include "flash.h" #include "ui_mainwindow.h" #include "configdialog.h" #include "dataexport.h" #include "sleeper.h" #include "aboutdialog.h" #include "parameters.h" #include "paramfile.h" #include <QTextBrowser> #include "renderer.h" extern ChirpProc c_grabFrame; MainWindow::MainWindow(int argc, char *argv[], QWidget *parent) : QMainWindow(parent), m_ui(new Ui::MainWindow) { QCoreApplication::setOrganizationName(PIXYMON_COMPANY); QCoreApplication::setApplicationName(PIXYMON_TITLE); qRegisterMetaType<Device>("Device"); m_ui->setupUi(this); setWindowTitle(PIXYMON_TITLE); m_interpreter = NULL; connect(m_interpreter->m_renderer,&Renderer::Rvalues,m_ui->textBrowser,&QTextBrowser::setText); m_flash = NULL; m_renderer = NULL; //<-------------------------This? m_pixyConnected = false; m_pixyDFUConnected = false; m_configDialog = NULL; m_fwInstructions = NULL; m_fwMessage = NULL; m_versionIncompatibility = false; m_testCycle = false; m_waiting = WAIT_NONE; parseCommandline(argc, argv); m_settings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, PIXYMON_COMPANY, PIXYMON_TITLE); m_console = new ConsoleWidget(this); m_video = new VideoWidget(this); connect(m_video, SIGNAL(mouseLoc(int,int)), this, SLOT(handleMouseLoc(int, int))); m_ui->imageLayout->addWidget(m_video); m_ui->imageLayout->addWidget(m_console); // hide console m_showConsole = m_testCycle; m_console->setVisible(m_testCycle); m_ui->actionConsole->setChecked(m_testCycle); m_ui->toolBar->addAction(m_ui->actionPlay_Pause); m_ui->actionDefault_program->setIcon(QIcon(":/icons/icons/home.png")); m_ui->toolBar->addAction(m_ui->actionDefault_program); m_ui->actionRaw_video->setIcon(QIcon(":/icons/icons/raw.png")); m_ui->toolBar->addAction(m_ui->actionRaw_video); m_ui->actionConfigure->setIcon(QIcon(":/icons/icons/config.png")); m_ui->toolBar->addAction(m_ui->actionConfigure); m_ui->menuProgram->setToolTipsVisible(true); m_statusLeft = new QLabel; m_statusRight = new QLabel; // give the status a little of a left margin m_ui->statusBar->setContentsMargins(6, 0, 0, 0); m_ui->statusBar->addWidget(m_statusLeft); m_ui->statusBar->addPermanentWidget(m_statusRight); updateButtons(); m_parameters.add("Pixy start command", PT_STRING, "", "The command that is sent to Pixy upon initialization"); // start looking for devices m_connect = new ConnectEvent(this); if (m_connect->getConnected()==NONE) error("No Pixy devices have been detected.\n"); // <---My added expermiental code ------v //connect(m_renderer,SIGNAL(Rvalues(QString)), m_ui->textBrowser, SLOT(setText(QString))); // connect(m_interpreter->m_renderer,&Renderer::Rvalues,m_ui->textBrowser,&QTextBrowser::setText); }