Results 1 to 4 of 4

Thread: clicked signal from QMainWindow

  1. #1
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default clicked signal from QMainWindow

    Hello!

    I want to do something like this: clicking on 'lock' button should lock the screen (disable all objects), and clicking anywhere on QMainWindow should do some actions, and then unlock the window. Since there is not such a thing like clicked signal emitted from QMainWindow I'm wondering how can I check if the window was clicked while 'lock' state.

    thanks in advance
    best regards
    Tomasz

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: clicked signal from QMainWindow

    Since there is not such a thing like clicked signal emitted from QMainWindow I'm wondering how can I check if the window was clicked while 'lock' state.
    see mousePressEvent().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    Tomasz (13th December 2010)

  4. #3
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: clicked signal from QMainWindow

    Thanks! I've reimplemented this function:

    Qt Code:
    1. void MainWindow::mousePressEvent(QMouseEvent *event)
    2. {
    3. QTextStream out(stdout);
    4.  
    5. if(event->button()==Qt::LeftButton)
    6. {
    7. out << "test" << endl;
    8. }
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    And it works just fine. One more question. When I've reimplemented it, it will be working all the time that way. Can I make it work this way only in my 'lock' mode? I think I can use some variable to detect that mode, but is this the only way?

    thanks in advance
    best regards
    Tomasz

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: clicked signal from QMainWindow

    I am not quite sure I understand your last question.
    One way you could go about it, is just emit a signal in your mousePressEvent(), and in the slot you can have the logic for doing things depending on your mode, as you wanted in your original question.
    But that is only a semantic difference.
    You can just as well do that in the mousePressEVent().

    P.S
    Instead of using QTextStream for debug messages you can use qDebug().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:

    Tomasz (13th December 2010)

Similar Threads

  1. clicked() signal for QLineEdit
    By smarinr in forum Qt Programming
    Replies: 10
    Last Post: 26th June 2019, 16:35
  2. QTreeWidget clicked signal
    By ^NyAw^ in forum Qt Programming
    Replies: 41
    Last Post: 30th January 2010, 11:42
  3. signal mapping on pushbutton signal clicked
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 07:54
  4. disable clicked() signal
    By mattia in forum Newbie
    Replies: 2
    Last Post: 27th February 2008, 10:27
  5. QListWidget clicked signal
    By asieriko in forum Qt Programming
    Replies: 12
    Last Post: 10th August 2007, 15:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.