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. [SOLVED] Shift + Mouseclick

[SOLVED] Shift + Mouseclick

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.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.
  • W Offline
    W Offline
    Woody
    wrote on 5 Jun 2012, 07:26 last edited by
    #1

    Hi all

    I got a question.

    I have button that has to do 2 things.
    When clicked:
    Go to a function
    When shift + clicked:
    Go to somewhere else

    I have tried it with a keypressEvent, catching the shift key and changing the connect(SIGNAL, SLOT), but it doesn't seem to catch that.

    Then I tried to install an eventfilter, which results in nothing either. Anyone got any idea for me?

    You would be of great help! Thanks

    File not found. Nobody leave the room!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 5 Jun 2012, 08:03 last edited by
      #2

      Hi,

      the event filter should work if you do it correctly :-) How did you do it? Could you share some code?

      The other option would be, subclass the button, overwrite mouse events and emit additional signals when shift click the button.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Woody
        wrote on 5 Jun 2012, 08:11 last edited by
        #3

        I think it is working. I don't know what I was doing wrong, but now it works fine.

        The code:
        @bool EventWidget::eventFilter(QObject *obj, QEvent *event)
        {
        //qDebug() << event->key();
        if (event->type() == QEvent::MouseButtonPress)
        {
        if(Qt::ShiftModifier == QApplication::keyboardModifiers())
        {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
        if(mouseEvent)
        {
        if (mouseEvent->button() == Qt::LeftButton)
        {
        //I do the other thing here.
        return true;
        }
        }
        }
        }
        return QWidget::eventFilter(obj, event);
        }@

        And this, apparently, works just fine. So its [SOLVED]

        File not found. Nobody leave the room!

        1 Reply Last reply
        0

        1/3

        5 Jun 2012, 07:26

        • Login

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