Results 1 to 6 of 6

Thread: using cut(), copy(), paste()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: using cut(), copy(), paste()

    Let's say you have a class called Window which contains those line edits.

    You would begin with declaring a new custom slot:
    Qt Code:
    1. class Window : public WhatEver
    2. {
    3. Q_OBJECT // <---
    4. public:
    5. [...]
    6.  
    7. private slots:
    8. void copy(); // <---
    9. };
    To copy to clipboard, switch view to plain text mode 

    Then, instead of connecting to each line edit's copy(), you would connect to this custom slot we declared above:
    Qt Code:
    1. connect(action_Copy,SIGNAL(triggered()),this,SLOT(copy()));
    To copy to clipboard, switch view to plain text mode 

    Finally, you would implement the custom slot. More or less something like this:
    Qt Code:
    1. void Window::copy()
    2. {
    3. // get the last child widget which has focus and
    4. // try to cast it as line edit
    5. QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(focusWidget());
    6. if (lineEdit)
    7. {
    8. // it was a line edit, perform copy
    9. lineEdit->copy();
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    fnmblot (18th December 2007)

Similar Threads

  1. Mac: Copy Files Build Phase and qmake...
    By kuwan in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2007, 20:59
  2. copy and run a .exe file in another system
    By sabeesh in forum Installation and Deployment
    Replies: 3
    Last Post: 22nd August 2007, 10:05
  3. Copy progress bar
    By safknw in forum Newbie
    Replies: 13
    Last Post: 16th September 2006, 09:02
  4. file copy in Qt 3.3.4 ?
    By npc in forum Newbie
    Replies: 6
    Last Post: 31st March 2006, 14:43

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.