Results 1 to 8 of 8

Thread: 5 QlineEdits - 1 Button => How to copy text with less steps?

  1. #1
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default 5 QlineEdits - 1 Button => How to copy text with less steps?

    So I have a form with some text fields(with text inside..) and a "Copy" button,which currently works as QLineEdit1 > text > copy.
    The program itself is a kind of shortcut,I mean instead of having a notepad with notes and hover each line then copy it,I made some fields to hold these notes and I want to make it as simple(very few steps)as possible to use(the text: copy,insert...).

    So,I don't want to make 10 btns for each text box and use the sender() function...
    What are some better ways to do it?For example double-click the text in any lineedit and it copies?Or something like that.
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    I would go for one line edit one button. That is the most intuitive approach. And you don't need to use sender or something like that for it. Just make your own widget containing the line edit and the button. In your main application just create x times that custom widget.

  3. #3
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    How can I create that widget?
    And also lets say I have lineE1 + btn1 and the button copies text from lE1.
    If I paste the widget some times,the name remain same,so everything will be upside-down..or?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    Create it by subclass QWidget. And as for the number, just introduce a private member with a setter function.

  5. #5
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    How can I also double click the text inside and it copies?

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    Just reimplement the double click event handler of the line edit.

  7. #7
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    Can I have some more info(maybe examples) on QWidget subclassing?
    Thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 5 QlineEdits - 1 Button => How to copy text with less steps?

    The examples are full of subclassed widgets. If you make a new application your main class is a subclass of QMainWindow...
    Qt Code:
    1. class MyClass : public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. //...
    6. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Changing text of button in no relation to button
    By Sabre Runner in forum Newbie
    Replies: 22
    Last Post: 23rd September 2010, 13:29
  2. Replies: 6
    Last Post: 21st August 2010, 22:09
  3. Replies: 1
    Last Post: 3rd February 2010, 08:44
  4. Problem with copy text to clipboard
    By weiching in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2008, 13:44
  5. copy string from text box
    By Rekha in forum Newbie
    Replies: 6
    Last Post: 27th July 2006, 20:21

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.