Results 1 to 11 of 11

Thread: QLabel text change signal question

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QLabel text change signal question

    Which signal is emmited if text in QLabel is changed?
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    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: QLabel text change signal question

    None, because it's not a dynamic property which has tendency to change over time. It's always you who changes it, programmatically.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QLabel text change signal question

    Well, this is not good since then I and you have a problem. I have a QFileDialog, which appearance slot is connected to "Browse button...". Once a file is selected, its path and filename are shows in QLabel and now I have to catch this event. Should I use some other class for showing path and filename or how to catch it?
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    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: QLabel text change signal question

    Who sets the filename on the label in the first place?
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QLabel text change signal question

    Well, I have a widget (QDialog) which contains:
    - QLabel containting path and filename of file
    - QPushButton "Browse" that invokes QFileDialog

    and once user presses Ok in QFileDialog, the selected file (with path and filename) is transferred to QLabel i mentioned before. Now I need to catch the QLabel text change.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    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: QLabel text change signal question

    Well, QLabel doesn't offer such signal so why don't you make the dialog emit the change? It's the one who knows about the change. Besides, the label is a private component of the dialog. Who is interested of the change anyway? Something inside or outside the dialog?
    J-P Nurmi

  7. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QLabel text change signal question

    The settings class subclassed from QSettings is interested in a change, since the filename path and name are saved into ini file.
    Last edited by MarkoSan; 28th March 2008 at 09:34.
    Qt 5.3 Opensource & Creator 3.1.2

  8. #8
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QLabel text change signal question

    I had a similar problem, but I "solved" it by intercepting the answer of the QFileDialog.
    I mean, the dialog has anyway to be called by a function, so the same function could check if the dialog's ok flag is true, in that case emit your signal... well, I did so and it works fine.
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  9. #9
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QLabel text change signal question

    Quote Originally Posted by Raccoon29 View Post
    I had a similar problem, but I "solved" it by intercepting the answer of the QFileDialog.
    I mean, the dialog has anyway to be called by a function, so the same function could check if the dialog's ok flag is true, in that case emit your signal... well, I did so and it works fine.
    Did you emit custom made signal or some predefined signal? Can you pls give me example?
    Qt 5.3 Opensource & Creator 3.1.2

  10. #10
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QLabel text change signal question

    I've done it!

    Thanks for your help. So, I've added custom signal, which is emitted after qfiledialog exec() function and it works ok.
    Qt 5.3 Opensource & Creator 3.1.2

  11. #11
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QLabel text change signal question

    Glad it worked.

    Just a point: with the signal emitted by exec, make that signal emitted even if the dialog get aborted ("Cancel") so, just be aware of this
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 8
    Last Post: 15th May 2007, 09:21
  3. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25
  4. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03

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.