Results 1 to 2 of 2

Thread: check box unchecked should undo action?

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default check box unchecked should undo action?

    Hi,
    I think I'm missing something easy. I have a slot that is called when a checkbox is checked. It makes the text in a textEdit become right justified. I want the text to be sent back to the left when I uncheck the box, How do I do that?

    I have tried using all the different signals for qcheckbox

    this is my code

    Qt Code:
    1. connect(checkAxis, SIGNAL(pressed()), this, SLOT(setAxis()));
    2.  
    3. void MyWidget::setAxis(){
    4. QTextCursor cursorArea = textedit->textCursor();
    5. QTextBlockFormat textblock = cursorArea.blockFormat();
    6. textblock.setAlignment(Qt::AlignRight);
    7. cursorArea.setBlockFormat(textblock);
    8. }
    To copy to clipboard, switch view to plain text mode 

    I also tried making a second slot that is the same as setAxis, just it aligns left, and connect it with released, but that didn't work either.

    Qt Code:
    1. connect(checkAxis, SIGNAL(released()), this, SLOT(setAxisBack()));
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: check box unchecked should undo action?

    Use the toggled(bool) signal.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    kja (29th November 2010)

Similar Threads

  1. How can i implement "Undo" action?
    By suseway in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2010, 11:32
  2. Replies: 8
    Last Post: 2nd February 2009, 12:25
  3. buggy undo example
    By Gopala Krishna in forum Qt Programming
    Replies: 2
    Last Post: 21st August 2007, 19:33
  4. Detecting a action ( undo/ redo)
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 5th May 2006, 05:05
  5. No action checked in an exclusive action group
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 13th February 2006, 06:19

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
  •  
Qt is a trademark of The Qt Company.