Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DoubleClick not work when double click QListWidget item
Qt 6.11 is out! See what's new in the release blog

DoubleClick not work when double click QListWidget item

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.4k 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.
  • H Offline
    H Offline
    hitbuyi
    wrote on last edited by hitbuyi
    #1

    myClass:public QMainWindow{
    Q_OBJECT
    public:
    myClass(QWidget *parent = Q_NULLPTR);
    public slots:
    void myItemDoubleClicked(QListWidgetItem *item);
    }

    myClass::myClass(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);

    listWidget1 = new QListWidget; // listWidget1 declared in *.h file as pulic type
    listWidget1->setObjectName(QStringLiteral("listWidget1"));
    listWidget1->setGeometry(QRect(550, 290, 256, 111));
    bool bc = connect(listWidget1, SIGNAL(ItemDoubleClicked(QListWidgetItem *)), this, SLOT(myItemDoubleClicked(QListWidgetItem *)));
    }

    void Myclass::myItemDoubleClicked(QListWidgetItem *item){
    int i;
    i = 100;
    }

    connet failed, when I doubly click item on QListWidget, can not enter Myclass::myItemDoubleClicked(QListWidgetItem *item){}

    my platform is VS2015+QT5.9.9

    thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • H hitbuyi

      myClass:public QMainWindow{
      Q_OBJECT
      public:
      myClass(QWidget *parent = Q_NULLPTR);
      public slots:
      void myItemDoubleClicked(QListWidgetItem *item);
      }

      myClass::myClass(QWidget *parent)
      : QMainWindow(parent)
      {
      ui.setupUi(this);

      listWidget1 = new QListWidget; // listWidget1 declared in *.h file as pulic type
      listWidget1->setObjectName(QStringLiteral("listWidget1"));
      listWidget1->setGeometry(QRect(550, 290, 256, 111));
      bool bc = connect(listWidget1, SIGNAL(ItemDoubleClicked(QListWidgetItem *)), this, SLOT(myItemDoubleClicked(QListWidgetItem *)));
      }

      void Myclass::myItemDoubleClicked(QListWidgetItem *item){
      int i;
      i = 100;
      }

      connet failed, when I doubly click item on QListWidget, can not enter Myclass::myItemDoubleClicked(QListWidgetItem *item){}

      my platform is VS2015+QT5.9.9

      thanks in advance.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @hitbuyi said in DoubleClick not work when double click QListWidget item:

      ItemDoubleClicked

      This is wrong, correct signal name is itemDoubleClicked.
      To avoid such problems you should use new Qt5 connect syntax.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • H Offline
        H Offline
        hitbuyi
        wrote on last edited by
        #3

        It really solved my problem
        BYW, how to using QT5 new conect syntax to rewrite this sentence, sorry, i am new to QT

        jsulmJ 1 Reply Last reply
        0
        • H hitbuyi

          It really solved my problem
          BYW, how to using QT5 new conect syntax to rewrite this sentence, sorry, i am new to QT

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @hitbuyi said in DoubleClick not work when double click QListWidget item:

          how to using QT5 new conect syntax

          https://wiki.qt.io/New_Signal_Slot_Syntax

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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