Solved QObject::connect: Cannot connect (null)::clicked() to ScanFrame::OnBtnStartScanClicked()
-
@SGaist : Its being called _ui->setupUi(this);
-
@jsulm: Also I am trying to display image on QLabel its not being displayed.
I checked the slot is being called but the image is not being displayed.
Please refer to the below slot code.QPixmap pix; pix.load("cat.jpg"); pix.scaled(_ui->lblROICamera->size(), Qt::KeepAspectRatio); _ui->lblCamera->setPixmap(QPixmap::fromImage(img));
-
Because the path to that picture is relative so unless you have that file in the same folder as the executable, it won't be loaded.
-
@SGaist :its present. I verified, actually, I haved worked with images multiple times, don't know y its showing strange behavior;
-
@Kira said in QObject::connect: Cannot connect (null)::clicked() to ScanFrame::OnBtnStartScanClicked():
its present
executable, not project file!
-
@J-Hilk :ohh.
Executable is being generated but its not in the debug folder. I have provided a separated folder for the exe file -
@Kira Is the image in the SAME directory as the executable?
-
@jsulm : One more thing I am using a promoted widget which is QFrame consisting of QLabel and QPushbutton.
When I put label in the base class the image gets displayed but when I write the same code in the promoted widget it is not being displayed.Base Widget label:
After pasting the similar code in promoted widget:
-
@Kira Without code I have no idea...
-
@jsulm : Every connect statement I get a warning : avoid unnamed object with custom constructor and destructor.
Also, I also figured the problem is in the slot of the promoted widget. When I try to write the code to display the image in constructor it works fine but when I add the same code in the slot it failed to display the image.
I have also checked that the slot is invoked every time by placing a breakpoint in the respective slot. -
@Kira Sorry, without code and exact error messages others can only guess...
-
@jsulm : Thanks for highlighting the issue.
As mentioned earlier, I had created a base widget and promoted widget.
In the designer, I promoted the widget, and in the class file of the base widget, I created an object of the promoted widget to pass some initialization parameter. There I called the signal to slot connection.I finally figured that the connections start working after I added them after
_ui->setupUi(this); or called them in showEvent().
Since _ui->setupUi(this); is declared in the constructor of the promoted widget. I never thought this could be the issue.
I finally got the example working by adding them in the showEvent()