Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Mouse click for latest Qt and VC++ problem....
QtWS25 Last Chance

Mouse click for latest Qt and VC++ problem....

Scheduled Pinned Locked Moved Solved Game Development
visual c++guimouse events
10 Posts 4 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tamis2018
    wrote on 3 Jul 2018, 14:28 last edited by aha_1980 7 Apr 2018, 09:29
    #1

    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_OBJECT

    public:
    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Jul 2018, 14:48 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply 4 Jul 2018, 07:59
      1
      • T Offline
        T Offline
        Tamis2018
        wrote on 3 Jul 2018, 21:47 last edited by
        #3

        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.

        1. //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…
        J 1 Reply Last reply 3 Jul 2018, 23:52
        0
        • T Tamis2018
          3 Jul 2018, 21:47

          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.

          1. //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…
          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 3 Jul 2018, 23:52 last edited by
          #4

          @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 -> ?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          T 1 Reply Last reply 4 Jul 2018, 09:14
          1
          • S SGaist
            3 Jul 2018, 14:48

            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.

            T Offline
            T Offline
            Tamis2018
            wrote on 4 Jul 2018, 07:59 last edited by
            #5

            0_1530690910709_showscreen.png

            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?

            1 Reply Last reply
            0
            • J JKSH
              3 Jul 2018, 23:52

              @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 -> ?

              T Offline
              T Offline
              Tamis2018
              wrote on 4 Jul 2018, 09:14 last edited by
              #6

              @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.

              J 1 Reply Last reply 4 Jul 2018, 09:25
              0
              • T Tamis2018
                4 Jul 2018, 09:14

                @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.

                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 4 Jul 2018, 09:25 last edited by
                #7

                @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

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                T 1 Reply Last reply 4 Jul 2018, 11:26
                2
                • J J.Hilk
                  4 Jul 2018, 09:25

                  @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
                  T Offline
                  T Offline
                  Tamis2018
                  wrote on 4 Jul 2018, 11:26 last edited by
                  #8

                  @J.Hilk

                  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.

                  J 1 Reply Last reply 5 Jul 2018, 00:47
                  1
                  • T Tamis2018
                    4 Jul 2018, 11:26

                    @J.Hilk

                    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.

                    J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 5 Jul 2018, 00:47 last edited by
                    #9

                    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:

                    1. Start a new project in Linux and try to make it work again.
                    2. Repeat this process in Windows. (Make sure you do everything the same way. Everything!)

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    T 1 Reply Last reply 5 Jul 2018, 08:13
                    2
                    • J JKSH
                      5 Jul 2018, 00:47

                      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:

                      1. Start a new project in Linux and try to make it work again.
                      2. Repeat this process in Windows. (Make sure you do everything the same way. Everything!)
                      T Offline
                      T Offline
                      Tamis2018
                      wrote on 5 Jul 2018, 08:13 last edited by
                      #10

                      @JKSH

                      Yes, I had to reinstalled QT on Visual C++. Works OK...
                      THANKS!!!

                      1 Reply Last reply
                      0

                      10/10

                      5 Jul 2018, 08:13

                      • Login

                      • Login or register to search.
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved