Mouse click for latest Qt and VC++ problem....
-
It is very simple application, and there is only mouse, which when clicked should generate Qdebug message ""test". However, there is a problem. On Visual studio I can not generate subroutine 0n_button_clicked() as it is on non MSVC++ environment.
I have followed the advice from discussion forum to go to QTdesigner that to Signal/Slots editor. Unfortunately I could not find my class and clickConfigure(). What I have done wrong?Why commented:
connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure)); also does not work, which complains about ui "Severity Code Description Project File Line Suppression State
Error C2819 type 'Ui::acatest2Class' does not have an overloaded member 'operator ->' acatest2 e:\jpegsoft\acatest2\acactest2\acatest2.cpp 8
"Here is excerp from my very simple code:
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_acactest2.h"class acatest2 : public QMainWindow
{
Q_OBJECTpublic:
acactest2(QWidget *parent = Q_NULLPTR);private slots:
void clickConfigure();
private:
Ui::acactest2Class ui;
};and cpp file...
#include "acactest2.h"
#include <Qdebug>acactest2::acactest2(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
//connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure));
}void acactest2::clickConfigure()
{
qDebug() << "test";
}What is problem with that? Why I did not have any problem on Linux?
-
Hi,
mouseDoubleClickEvent is not a signal so what you are doing is wrong.
If you want to send a signal from it, then re-implement that function in your subclass.
-
1.Well, I want to have on mainwindow only pushbutton for testing. I dragged it there. However, I could not get after:
ui->setUi(this) (that is done for me)this:
ui->pushbutton->settext('' Test'') just right after ui could not get available options to choose.
2. When I right click on pushbutton I could not get option 'go slot'? and from there just like on tutorials . From there select signal clicked from qAbstractButton.- //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure));
I have tried to put it myself and that is what I was able to choose from. Probably garbage…
- //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure));
-
1.Well, I want to have on mainwindow only pushbutton for testing. I dragged it there. However, I could not get after:
ui->setUi(this) (that is done for me)this:
ui->pushbutton->settext('' Test'') just right after ui could not get available options to choose.
2. When I right click on pushbutton I could not get option 'go slot'? and from there just like on tutorials . From there select signal clicked from qAbstractButton.- //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure));
I have tried to put it myself and that is what I was able to choose from. Probably garbage…
@Tamis2018 said in Mouse Click for Latest QT and VC++ problem....:
Why commented:
connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure)); also does not work, which complains about ui "Severity Code Description Project File Line Suppression State
Error C2819 type 'Ui::acatest2Class' does not have an overloaded member 'operator ->' acatest2 e:\jpegsoft\acatest2\acactest2\acatest2.cpp 8
"Because in your code,
ui
is not a pointer.acactest2::acactest2(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure)); }
- Line 1 has
ui.
- Line 2 has
ui->
Which one are you using?
.
or->
? - //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure));
-
Hi,
mouseDoubleClickEvent is not a signal so what you are doing is wrong.
If you want to send a signal from it, then re-implement that function in your subclass.
Well, I did change to be as pointer. The problems boils down to this:
#include <QtWidgets/QMainWindow>
#include "ui_acactest2.h"class acatest2 : public QMainWindow
{
Q_OBJECT
public:
acactest2(QWidget *parent = Q_NULLPTR);
public slots:
void clickConfigure();
private:
Ui::acatest2Class *ui;
};Why I am not having clickConfigure() as option to choose as slot as it is shown in image included?
-
@Tamis2018 said in Mouse Click for Latest QT and VC++ problem....:
Why commented:
connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure)); also does not work, which complains about ui "Severity Code Description Project File Line Suppression State
Error C2819 type 'Ui::acatest2Class' does not have an overloaded member 'operator ->' acatest2 e:\jpegsoft\acatest2\acactest2\acatest2.cpp 8
"Because in your code,
ui
is not a pointer.acactest2::acactest2(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); //connect(ui->buttonConfigure, SIGNAL(mouseDoubleClickEvent), this, SLOT(clickConfigure)); }
- Line 1 has
ui.
- Line 2 has
ui->
Which one are you using?
.
or->
? - Line 1 has
-
@JKSH said in Mouse Click for Latest QT and VC++ problem....:
Which one are you using? . or -> ?
I was desperate and try both with same results.
@Tamis2018
you should read up on your c++,- Address-of operator (&)
- Dereference operator (*)
and - Arrow-Operator (->) aka Dereference of an Address-of Operator: foo->bar = (*foo).bar
-
@Tamis2018
you should read up on your c++,- Address-of operator (&)
- Dereference operator (*)
and - Arrow-Operator (->) aka Dereference of an Address-of Operator: foo->bar = (*foo).bar
I know that...
The problem is that I can do that like:
https://wiki.qt.io/How_to_Use_QPushButton
or when I put this:
private slots:
void handleButton();
private:
QPushButton *m_button;and this:
m_button = new QPushButton("My Button", this);
// set size and location of the button
m_button->setGeometry(QRect(QPoint(100, 100),
QSize(200, 50)));// Connect button signal to appropriate slot connect(m_button, SIGNAL (released()), this, SLOT (handleButton()));
}
void MainWindow::handleButton()
{
// change the text
m_button->setText("Example");
// resize button
m_button->resize(100,100);
}
(I could not see that button in QDesigner, but it creates button in run state)And that works! But other way around is described.
-
I know that...
The problem is that I can do that like:
https://wiki.qt.io/How_to_Use_QPushButton
or when I put this:
private slots:
void handleButton();
private:
QPushButton *m_button;and this:
m_button = new QPushButton("My Button", this);
// set size and location of the button
m_button->setGeometry(QRect(QPoint(100, 100),
QSize(200, 50)));// Connect button signal to appropriate slot connect(m_button, SIGNAL (released()), this, SLOT (handleButton()));
}
void MainWindow::handleButton()
{
// change the text
m_button->setText("Example");
// resize button
m_button->resize(100,100);
}
(I could not see that button in QDesigner, but it creates button in run state)And that works! But other way around is described.
You say you were able to do it in Linux.
@Tamis2018 said in Mouse click for latest Qt and VC++ problem....:
Why I did not have any problem on Linux?
It is not working on Windows because you did something differently.
You should do this:
- Start a new project in Linux and try to make it work again.
- Repeat this process in Windows. (Make sure you do everything the same way. Everything!)
-
You say you were able to do it in Linux.
@Tamis2018 said in Mouse click for latest Qt and VC++ problem....:
Why I did not have any problem on Linux?
It is not working on Windows because you did something differently.
You should do this:
- Start a new project in Linux and try to make it work again.
- Repeat this process in Windows. (Make sure you do everything the same way. Everything!)