Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    Game Development
    visual c++ gui mouse events
    4
    10
    2102
    Loading More Posts
    • 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
      Tamis2018 last edited by aha_1980

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • T
          Tamis2018 last edited by

          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…
          JKSH 1 Reply Last reply Reply Quote 0
          • JKSH
            JKSH Moderators @Tamis2018 last edited by

            @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 Reply Quote 1
            • T
              Tamis2018 @SGaist last edited by

              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 Reply Quote 0
              • T
                Tamis2018 @JKSH last edited by

                @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.Hilk 1 Reply Last reply Reply Quote 0
                • J.Hilk
                  J.Hilk Moderators @Tamis2018 last edited by

                  @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

                  Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

                  T 1 Reply Last reply Reply Quote 2
                  • T
                    Tamis2018 @J.Hilk last edited by

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

                    JKSH 1 Reply Last reply Reply Quote 1
                    • JKSH
                      JKSH Moderators @Tamis2018 last edited by

                      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 Reply Quote 2
                      • T
                        Tamis2018 @JKSH last edited by

                        @JKSH

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

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post