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. how to have double click on a image on single click
Qt 6.11 is out! See what's new in the release blog

how to have double click on a image on single click

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 3.1k Views 2 Watching
  • 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I display a QPixMap in QTreevIew . When the user double clicks on the image I should bring QColorDialog

    I tried following code but I can get the behavior on single click but I want the behavior only on double click

    MyInstView::myInstView(QWidget* dparent)
    : QTreeView(dparent),
    {
    connect(this, SIGNAL(clicked(const QModelIndex&)),
    this, SLOT(clickInstance(const QModelIndex&)));
    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why not use the doubleClicked signal ?

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

      1 Reply Last reply
      1
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #3

        Hi, try connect(this,SIGNAL(doubleclicked(const QModelIndex&)),

        1 Reply Last reply
        2
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          I am getting following message when I start my GUI

          Object::connect: No such signal GQInstView::doubleclicked(QModelIndex)

          the code is as follows -----
          GQInstView::GQInstView(QWidget* dparent)
          : QTreeView(dparent), model(0),
          {
          QObject::connect(this, SIGNAL(doubleclicked(const QModelIndex&)), this, SLOT(clickInstance(const QModelIndex&)));
          }

          Is there anything I am missing

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Because it's doubleClicked. Casing is important.

            If you are using Qt 5, then you should go for the new syntax. That would have already failed at compile time.

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

            1 Reply Last reply
            1
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Yes @SGaist is correct and sorry, it was my bad speeling :-)

              1 Reply Last reply
              0

              • Login

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