[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Rounding values in QT Number
From: |
CEL |
Subject: |
Re: [Discuss-gnuradio] Rounding values in QT Number |
Date: |
Tue, 6 Mar 2018 13:47:34 +0000 |
Hi John,
there's no dumb questions, maybe badly researched ones, and you
definitely don't have the habit of posting the latter, so: Good
question!
It all boils down to this line in gnuradio/gr-
qtgui/lib/numberdisplayform.cc:
d_text_box[i]->setText(QString("%1 %2").arg(f, 4, ' ').\
arg(QString(d_unit[i].c_str())));
in which the current value `f` is displayed with four digits after the
decimal dot.
I'd agree this is probably not what's desirable in any application.
Now, this can be changed; for example, we could add a way to set the
number of digits variably instead of to 4. However, that'll be a source
code and API change, so it'll require recompilation of GNU Radio and
relinking of everything that use gr-qtgui. Does that help you?
Best regards,
Marcus
On Mon, 2018-03-05 at 16:36 -0500, John Ackermann N8UR wrote:
> I hate to put such a dumb question to the list, but I'm going nuts
> trying to do something that ought to be simple.
>
> I am using a QT Number Sink to display dB values in float format. It is
> showing many more decimal places than have any meaning. I'd like to
> round the display to one or two decimal places.
>
> I tried making an embedded python block to do the rounding and finally
> succeeded (it was a long and painful process, and frankly I don't
> understand why I had to do what I did to get it to work), but the number
> sink is still printing all the extra decimal places, they're just now
> set to zero.
>
> Is there any trick to round or even just truncate the number of decimal
> places shown in the QT Number Sink?
>
> Thanks,
> John
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
smime.p7s
Description: S/MIME cryptographic signature