Page 1 of 2 12 LastLast
Results 1 to 20 of 37

Thread: Is there a widget for this?

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

    Default Is there a widget for this?

    This time I need to make a runtime edited tool.
    What I mean is:I need to have a tool that has several text-boxes(vertically placed) and each of those boxes will have text,that the user can edit,hen he double clicks it.

    When the text has changed,the box saves that text and shows each time the app is ran...
    An example of this might be the common windows name chnage.When you double click the icon you get the ability to edit its name..:/

    Something like this.Any suggestions?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    What's wrong with QLineEdit?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    But line edit won't save the text for the next app start.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    No widget will. You have to implement it yourself. Either as a QLineEdit subclass or as a QComboBox subclass. You can use QSettings for storing the data.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    What code should I write in line-edit subclass and I didn't understand how qsetting can help me with this problem.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    QSettings allow you to store some data and load it back next time the application is started. I don't know what you should write in QLineEdit subclass (I don't know if you even need to subclass QLineEdit), it depends what you want to do. Programming is something more than just taking ready components and connecting them together.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    I just need a method to make the lineedit save that text for every start up.
    You tell me how to do this.

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Is there a widget for this?

    You tell me how to do this.
    Read the QSettings documentation, everything is explained there (pay attention to setValue() / value() methods).

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    Quote Originally Posted by "BumbleBee" View Post
    I just need a method to make the lineedit save that text for every start up.
    You tell me how to do this.
    As far as I remember we've done that using QCompleter and QSettings and a bit of smart code that looked for all line edits in the form and tried to retrieve previous values for them from settings.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    Nah..completer doesn't help me with this.
    And although I read the qsetting doc. I can't really understand how I attach it to the lineedit..:/

    Any example code for my problem?
    Thanks

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    You don't attach QSettings to a line edit. I already told you, it's not always as easy as calling one method on an object passing it the other object. You need to implement everything you need on your own. I don't even know what you want to do since you said completer is not what you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there a widget for this?

    EDIT:- late

    you dont have to attach anything. Its just a simple transfer of data (QString) to and fro (QSettings to LineEdit).
    something like
    settings->setValue(lineEdit.text())
    lineEdit.setText(settings.value()).

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

    Default Re: Is there a widget for this?

    Quote Originally Posted by nish View Post
    EDIT:- late

    you dont have to attach anything. Its just a simple transfer of data (QString) to and fro (QSettings to LineEdit).
    something like
    settings->setValue(lineEdit.text())
    lineEdit.setText(settings.value()).
    Added you on skype.Please approve me.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    Quote Originally Posted by "BumbleBee" View Post
    Added you on skype.Please approve me.
    I wouldn't count on him doing that
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    Why?
    Someone help me please....

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    Because you'll start bombarding him with requests to fix things for you. Currently it looks like you have totally no idea how to solve your problem. Moreover it looks like you are not willing to do any thinking yourself, you just want a ready solution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    Oh..I have never used settings before,now I watched a YT tutorial on these..but I can't see to get how to impletment it to qlineedit.
    http://www.youtube.com/watch?v=TNIkeFfzH-g


    Added after 16 minutes:


    Anyway did this.
    Qt Code:
    1. void Table::loadSettings()
    2. {
    3. QSettings set("iWhor","whor");
    4. set.beginGroup("setting");
    5. QString text = set.value("text").toString();
    6. ui->le->setText(text);
    7. set.endGroup();
    8. }
    9.  
    10. void Table::saveSettings()
    11. {
    12. QSettings set("iWhor","whor");
    13. set.beginGroup("setting");
    14. set.setValue("text", ui->le->text());
    15. set.endGroup();
    16. }
    17.  
    18. void Table::on_load_tbn_clicked()
    19. {
    20. loadSettings();
    21. }
    22.  
    23. void Table::on_save_btn_clicked()
    24. {
    25. saveSettings();
    26. }
    27.  
    28. //Plus called loadSettings in constr.
    To copy to clipboard, switch view to plain text mode 

    Thank you all and please lock thread!


    Added after 27 minutes:


    Acuualy I'm not 100$% done.
    This ssems tow work only once and doesn't let me to edit the text later.
    However this si what I need.Among the other I need to edit text every now and then.How to?
    Last edited by "BumbleBee"; 13th October 2011 at 12:09.

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    Come on, if you know how to store a single string, it should be easy for you to discover how to store a list of strings.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Is there a widget for this?

    Quote Originally Posted by wysota View Post
    Come on, if you know how to store a single string, it should be easy for you to discover how to store a list of strings.
    And what about the fact that it doesn't change the setting?
    This seems to work only once(save the text) and doesn't let me to edit the text later.
    However this is what I need.Among the others, I need to edit text every now and then.How to?

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there a widget for this?

    Lay down on your bed, close your eyes, relax. Once you reach the state of emptiness in your mind, start thinking about your problem. If you didn't have any framework to help you, how would you solve the problem conceptually? After you're done thinking, write it down as a list of steps to perform and post it here.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 8
    Last Post: 28th June 2011, 15:57
  2. Replies: 1
    Last Post: 24th June 2011, 00:09
  3. Replies: 1
    Last Post: 11th March 2011, 20:34
  4. Replies: 7
    Last Post: 14th January 2010, 09:47
  5. Replies: 4
    Last Post: 3rd March 2008, 23:15

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.