PDA

View Full Version : QLabel text change signal question



MarkoSan
28th March 2008, 08:14
Which signal is emmited if text in QLabel is changed?

jpn
28th March 2008, 08:25
None, because it's not a dynamic property which has tendency to change over time. It's always you who changes it, programmatically.

MarkoSan
28th March 2008, 08:29
Well, this is not good since then I and you :D 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?

jpn
28th March 2008, 08:37
Who sets the filename on the label in the first place?

MarkoSan
28th March 2008, 09:09
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.

jpn
28th March 2008, 09:24
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?

MarkoSan
28th March 2008, 09:29
The settings class subclassed from QSettings is interested in a change, since the filename path and name are saved into ini file.

Raccoon29
28th March 2008, 09:34
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.

MarkoSan
29th March 2008, 03:04
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?

MarkoSan
29th March 2008, 06:12
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.

Raccoon29
5th April 2008, 10:19
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 :)