Results 1 to 4 of 4

Thread: Problem with "setModified(bool)"

  1. #1
    Join Date
    Jun 2007
    Location
    Melun (French)
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with "setModified(bool)"

    Hy, I'm a french student (15 years old) so sorry for my english

    Code 1)
    Qt Code:
    1. connect(textEdit, SIGNAL(textChanged()), SLOT(documentWasModified()));
    To copy to clipboard, switch view to plain text mode 

    With this code, when I launch my application, my title is always "myfile* - myapp"

    Code 2)
    Qt Code:
    1. connect(textEdit->document(), SIGNAL(textChanged()), SLOT(documentWasModified()));
    To copy to clipboard, switch view to plain text mode 

    With the code 2), when I make a modification in my textEdit, the title stays "myfile - myapp" instead of "myfile* - myapp".

    The code of "documentWasModified" :

    Qt Code:
    1. void MainWindowimpl::documentWasModified()
    2. {
    3. setWindowModified(textEdit->document()->isModified());
    4.  
    5. QString name;
    6. if (currentFile.isEmpty())
    7. {
    8. name = "sanstitre";
    9. }
    10. else
    11. {
    12. name = strippedName(currentFile);
    13. }
    14.  
    15. setWindowTitle(tr("%1[*] - %2").arg(name).arg(tr("SamSoft_DEV")));
    16. }
    To copy to clipboard, switch view to plain text mode 

    thank you in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with "setModified(bool)"

    code 1) You must reset the title after saving, so it is your job to make the * disappear.

    code 2) QTextDocument does not have a textChanged signal. Instead it provides the contentsChanged signal, but I'm guessing that using this won't make much difference over situation 1.

    The bottom line is that when you save the file, you must manually remove the * from the window title.
    For example, if you save with "CTRL+S", then in the slot connected to triggered() signal of this action, you parse the window title and remove the * from it, then you set it back.

    Regards

  3. #3
    Join Date
    Jun 2007
    Location
    Melun (French)
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Problem with "setModified(bool)"

    I'm going to try your solutions, thanks
    SamSoft

    http://www.samsoft.ift.fr

    The knowledge is a universal right, you must release the source code

  4. #4
    Join Date
    Jun 2007
    Location
    Melun (French)
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with "setModified(bool)"

    It's ok, my problem is resolved !

    Thank you
    SamSoft

    http://www.samsoft.ift.fr

    The knowledge is a universal right, you must release the source code

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.