[Qt-interest] QLabel text with colon always puts colon at the front
Keith Nicewarner
Keith.Nicewarner at spacex.com
Wed Jan 20 20:20:38 CET 2010
BTW, I'm using Qt 4.3.3.
Here's the context: I'm creating a custom designer plugin that instantiates a very simple widget that has a label and a line edit, both inside a horizontal layout. I used designer to create the form for the widget if that matters. My class looks like this:
class Text_Channel: public QWidget
{
Q_OBJECT
Q_PROPERTY(QString channel_name READ channel_name WRITE set_channel_name DESIGNABLE true)
public:
Text_Channel(QWidget * parent = 0);
QString channel_name() const;
void set_channel_name(QString const & name);
void set_value(double value);
private:
Ui_Form ui;
QString _channel_name;
};
The problem is here:
void Text_Channel::set_channel_name(QString const & name)
{
_channel_name = name;
ui.name->setText(name + ": ");
}
I'm testing the custom widget in designer by dragging my text channel onto a form and setting the channel name property in designer.
Thanks,
Keith.
-----Original Message-----
From: KC Jones [mailto:kc at asperasoft.com]
Sent: Wednesday, January 20, 2010 11:15 AM
To: Keith Nicewarner
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QLabel text with colon always puts colon at the front
There must be some other factor involved. I cannot reproduce this in
my code in a trivial test. I was able to call setText("FOO:") on one
of my QLabel widgets in my dialog's constructor immediately after the
setupUi(this) call, and it worked as expected.
Is there anything about the context where you make the call that might
be relevant? Are there translations built in? Is this called in a
slot after the dialog has been opened?
On Wed, Jan 20, 2010 at 10:36 AM, Keith Nicewarner
<Keith.Nicewarner at spacex.com> wrote:
> This is very strange. I set the text with a trailing colon:
>
> ui.label->setText("FOO:");
>
> cout << ui.label->text().toStdString() << endl;
>
>
>
> And my printout confirms it's what I set: "FOO:". But the widget has
> ":FOO". I set the label text properties to PlainText, thinking maybe
> autotext was screwing it up, but that wasn't it. If I add a character after
> the colon, it works ("FOO:x") but not if I add a space ("FOO: ").
>
>
>
> Any ideas what's going on?
>
>
>
> Keith.
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list