×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    51

    How to select string in QTextEdit

    HI
    I want to select string,cut ,copy ,paste in QTextEdit.How can i do.Pls help if possible.

    For Reply Thanks.
    Jobayer

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: How to select string in QTextEdit

    Hi,

    I created a simple copy paste application (no pun intended) it has two Text Edits and buttons for copy&paste. All that you need to do is connect some signals and slots.

    Hope this helps you to get started

    http://doc.trolltech.com/4.5/qtextedit.html
    http://doc.trolltech.com/4.5/qclipboard.html
    (tested only with emulator)
    Code:
    #include "CopyPasteTesti.h"
    #include <QDebug>
    #include <QClipboard>
    #include <QMimeData>
    
    CopyPasteTesti::CopyPasteTesti(QWidget *parent)
        : QWidget(parent)
    {
    	ui.setupUi(this);
    	
    	ui.pasteButton->setEnabled(false);
    	ui.copyButton->setEnabled(false);
    		
    	connect(ui.textEdit, SIGNAL(copyAvailable (bool)), ui.copyButton,SLOT(setEnabled(bool)));
    	connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(togglePasteButton()));
    	connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyButtonPressed()));
    	connect(ui.pasteButton, SIGNAL(clicked()), this, SLOT(pasteButtonPressed()));
    }
    
    CopyPasteTesti::~CopyPasteTesti(){}
    
    void CopyPasteTesti::togglePasteButton()
    	{
    	const QMimeData *mimeData = QApplication::clipboard()->mimeData();
    	ui.pasteButton->setEnabled(mimeData->hasText());
    	}
    
    void  CopyPasteTesti::pasteButtonPressed()
    	{
    	ui.textEdit_2->paste();
    	}
    
    void CopyPasteTesti::copyButtonPressed()
    	{
    	ui.textEdit->copy();
    	}

    Br,
    Ilkka

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    51

    Re: How to select string in QTextEdit

    Many many thanks Ilkka
    For Quick Reply.

    BR
    Jobayer

Similar Threads

  1. Replies: 35
    Last Post: 2009-04-11, 14:36
  2. C++ 學習程序2
    By hanwen813 in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 32
    Last Post: 2009-04-02, 09:10
  3. How To Select Inclusive String
    By yingying_zheng in forum Symbian
    Replies: 0
    Last Post: 2004-07-02, 04:18
  4. How To Select String In Database?
    By yingying_zheng in forum Symbian
    Replies: 3
    Last Post: 2004-06-23, 10:23
  5. D211 new linux driver 1.04 not working !!
    By franz_meyer in forum Multimodecards
    Replies: 1
    Last Post: 2002-12-12, 08:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×