Results 1 to 7 of 7

Thread: QWebKit, QDataStream, QList

  1. #1
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWebKit, QDataStream, QList

    Hallo I have 2 problems:
    1. I do WebBrowser and when I set Application name
    Qt Code:
    1. QApplication a(argc, argv);
    2. a.setApplicationName("MyBrowser");
    3. Window w;
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. QCoreApplication::setApplicationName(QLatin1String("MyBrowser"));
    2. QCoreApplication::setApplicationVersion(QLatin1String("0.1"));
    To copy to clipboard, switch view to plain text mode 
    now signal iconChanged() never emit but when i don't set Application name all work good

    2. I take all history items to QList<QAction *> history;
    save function:
    Qt Code:
    1. QFile historyFile("/History.bin");
    2. if(!historyFile.open(QIODevice::WriteOnly))
    3. {
    4. return;
    5. }
    6. QDataStream out(&historyFile);
    7. out.setVersion(QDataStream::Qt_4_8);
    8. out << allHistoryAction;
    9. historyFile.flush();
    10. historyFile.close();
    To copy to clipboard, switch view to plain text mode 
    all work but in load:
    Qt Code:
    1. QFile historyFile("/History.bin");
    2. if(!historyFile.open(QIODevice::ReadOnly))
    3. {
    4. return;
    5. }
    6. QDataStream in(&historyFile);
    7. in.setVersion(QDataStream::Qt_4_8);
    8. in >> allHistoryAction;
    9. historyFile.close();
    To copy to clipboard, switch view to plain text mode 
    this don't work error:
    error: no match for 'operator>>' in 's >> t'
    Last edited by Viper666; 18th September 2012 at 19:36.

  2. #2
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebKit, QDataStream, QList

    Please I need it. The most important is second question i can't save history

  3. #3
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QWebKit, QDataStream, QList

    The answer is in the docs: link

  4. #4
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebKit, QDataStream, QList

    ??? i don' understand I use QDatastream operator>> but i have error if i do something bad pls post me some code

  5. #5
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QWebKit, QDataStream, QList

    From the linked page:
    This function requires the value type to implement operator>>()
    QAction does not have operator>>() or operator()<< implemented so you have to implement them.

    Something like the following:
    Qt Code:
    1. QDataStream & operator<< (QDataStream & outputStream, const QAction *act){
    2. outputStream << act->text() << act->shortcut(); // any properties you want to store
    3. return outputStream;
    4. }
    5.  
    6. QDataStream & operator>> (QDataStream & inputStream, QAction *&action){
    7. action = new QAction(0);
    8. QString text;
    9. inputStream >> text >> seq;
    10. action->setText(text);
    11. action->setShortcut(seq);
    12. return inputStream;
    13. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebKit, QDataStream, QList

    ok thanks but i don't know why operator << work and operator >> not

  7. #7
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebKit, QDataStream, QList

    and one else question i don't know how save connect or how connect all actions in list again

Similar Threads

  1. Qlist<QLabel *> in Qlist<QAction*>
    By Naahmi in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2011, 08:53
  2. Cast QList<Foo*> to QList<const Foo*>
    By vfernandez in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2010, 16:04
  3. Replies: 4
    Last Post: 20th August 2010, 13:54
  4. Store QList<T> in QVariant and stream to QDataStream?
    By razvan.petru in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2009, 09:10
  5. QDataStream and saving and loading QList
    By Noxxik in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2009, 22:02

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.