Results 1 to 11 of 11

Thread: Qtable : how can I copy-paste the selected rows in a Word document ?

  1. #1
    Join Date
    Mar 2006
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qtable : how can I copy-paste the selected rows in a Word document ?

    Hi,

    I would like to copy the selected cells of a QTable and paste them in a Word document. How can I do that ? I haven't seen in the Qt Assistant something that could help me...

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?


  3. #3
    Join Date
    Mar 2006
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    Yes, but the aim is to create the same array in the Word document than the selected rows of the QTable. And I don't know how I can manage to do this because I could make it by using QPixmap but I will have a picture in my Word document, no ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    You could try to encode that table in HTML or copy some table into clipboard and see how it was encoded. Other solution you might try is to use Word's COM interface --- it probably will be more reliable, but it also requires more work.

  5. #5
    Join Date
    Mar 2006
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    Quote Originally Posted by jacek
    You could try to encode that table in HTML or copy some table into clipboard and see how it was encoded.
    You mean using "QClipboard::setText" with a QString containing the code in HTML ?

    (Thank you for your quick answers !)

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    Quote Originally Posted by greencastor
    You mean using "QClipboard::setText" with a QString containing the code in HTML ?
    I would rather try QClipboard::setData() / QClipboard::setMimeData().

  7. #7
    Join Date
    Mar 2006
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    I must admit that I have difficulties understanding how to use the class "QMimeSource" (for the function "void Clipboard::setData ( QMimeSource * src )")...

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    Quote Originally Posted by greencastor
    I must admit that I have difficulties understanding how to use the class "QMimeSource" (for the function "void Clipboard::setData ( QMimeSource * src )")...
    You must create your own class that inherits from QMimeSource and implement all abstract methods.

    But first write a small application that dumps data from cliboard to see that Word puts there. You might try also clipbrd.exe, but it won't give you much information.

  9. #9
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    isn't there a generic way to do that for all word processing programms (openoffice writer, kword, abiword, ms word...)?

    regards..
    aman..

  10. #10
    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: Qtable : how can I copy-paste the selected rows in a Word document ?

    Quote Originally Posted by aMan
    isn't there a generic way to do that for all word processing programms (openoffice writer, kword, abiword, ms word...)?
    I suppose all of them support HTML as suggested by jacek.

    Qt Code:
    1. // qt4 code
    2. QMimeData* mime = new QMimeData;
    3. mime->setHtml("<table border=2><tr><td>1</td></tr><tr><td>2</td></tr></table>");
    4. QApplication::clipboard()->setMimeData(mime); // clipboard takes ownership of mimedata
    To copy to clipboard, switch view to plain text mode 

    Edit: seems to only work with MS Word, not with KWord nor OO..
    Last edited by jpn; 23rd August 2006 at 21:12.
    J-P Nurmi

  11. #11
    Join Date
    Mar 2006
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtable : how can I copy-paste the selected rows in a Word document ?

    Thank you guys, I'm going to test it !

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.