Notices


Reply
Thread Tools
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#11
Originally Posted by pichlo View Post
It took me a while to figure out that in Ohm's Law and Power calculations, one line edit was for results and not for the input. I think it should be made obvious immediately.
Same here I think that tabs could be scrapped as a whole, leaving only three input fields - user put two values, and the empty one is calculated upon hitting "calculate" (it would just need to check which field was left empty). If user put things at all three of them, either throw educational notification Or just don't allow input in 3th field, when 2 other ones are already occupied.

IDK how easy/hard the above would be to code in GUi, though.

/Estel

// Edit

This way, instead of different main menu items for law and power, we could have one "calculations" menu item, and specific calculations could be shown as tabs (instead of current tabs for "what you want to get as a result"). So we would have Ohm's law tab, power tab, etc...
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!
 
Posts: 2,290 | Thanked: 4,133 times | Joined on Apr 2010 @ UK
#12
Originally Posted by pichlo View Post
Thanks for bringing my attention to this thread.

Looks easy. Let me have a look. I can send you my updates by email.
That would be good, the code for the 4 band resistors is in C and should be solid.

I couldn't get 5 band resistors to work so I scrapped that for now.

It's the other calculators that are a bit sketchy.
If someone wants to help me get the code working, tidying up the UI with your suggestions should be a breeze.

The idea behind the multiple lineEdit's was so you could input any two values and receive an answer. However, I couldn't get this to work so that spawned the tabgroupbox, which I don't like TBH.

The colo(u)r's are Qt:Red and Qt:Blue etc IIRC, this is the simplest method to add colour in Qt but could be modified.
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.
 

The Following 2 Users Say Thank You to sixwheeledbeast For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#13
Sorry, a lot's been going on in my personal life in the past couple of weeks and all hobby development had to take a break. Having said that, I've had a look at your code and found it so easy to tweak that I got carried away and took a more adventurous approach with a big redesign which is not finished yet. Here is a taster (just a mock up for now) of what I came up with. Treat it as work in pogress, the final UI may look a bit different. I would also welcome any feedback to see if people think this is a way forward or better to scrap it and stay with the current design.
Attached Images
 
__________________
Русский военный корабль, иди нахуй!
 

The Following 4 Users Say Thank You to pichlo For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#14
A silly question, but does anyone know how to make Qt controls display characters like μ and Ω? Particularly QComboBox, if that makes any difference. When I just paste the characters in the source, rebuild and run the app, I get ̼A and k̩ intead of μA and kΩ.
__________________
Русский военный корабль, иди нахуй!
 
Posts: 203 | Thanked: 445 times | Joined on Mar 2010
#15
Have you saved the source as UTF-8? I'd imagine that should be enough.
 

The Following 2 Users Say Thank You to foobar For This Useful Post:
Posts: 1,417 | Thanked: 2,619 times | Joined on Jan 2011 @ Touring
#16
Outside of the scope of this app, but if you could find a searchable DB of chip and transistor codes that would be great to have offline searchable.
 
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#17
Originally Posted by foobar View Post
Have you saved the source as UTF-8? I'd imagine that should be enough.
How does that help? The characters show OK in the source (in Leafpad).
They show muddled up in the compiled app, like this:
Attached Images
 
__________________
Русский военный корабль, иди нахуй!
 
Posts: 203 | Thanked: 445 times | Joined on Mar 2010
#18
Originally Posted by pichlo View Post
How does that help? The characters show OK in the source (in Leafpad).
They show muddled up in the compiled app, like this:
As far as I know, Qt by default works with/expects stuff to be UTF-8-encoded.
If the output doesn't match what you put in the source then either Qt is set to expect something else, or your input is not UTF-8.

That said, leafpad seems to save UTF-8-encoded by default, so I'm at a loss.
 

The Following User Says Thank You to foobar For This Useful Post:
Copernicus's Avatar
Posts: 1,986 | Thanked: 7,698 times | Joined on Dec 2010 @ Dayton, Ohio
#19
Originally Posted by pichlo View Post
A silly question, but does anyone know how to make Qt controls display characters like μ and Ω? Particularly QComboBox, if that makes any difference. When I just paste the characters in the source, rebuild and run the app, I get ̼A and k̩ intead of μA and kΩ.
If at all possible, I prefer to avoid direct use of non-ascii characters in source code. (Even though that's getting to be a tough proposition these days...) Anyway, if you don't need to use too many characters, it isn't too hard to specify their Unicode values in a QChar object.

Ok, I've just thrown together a little bit of test code (into my Lanterne project), adding a few new lines to a QComboBox. The Unicode value for the Ohm character appears to be 0x2126, and for the "Micro Sign" appears to be 0xB5. Here's the code I put together for it:

Code:
  QString testString("Test of ohm char: ");
  testString += QChar(0x2126);
  ui->indicatorBrightnessComboBox->addItem(testString);
  QString testString2("Test of mu char: ");
  testString2 += QChar(0x00B5);
  ui->indicatorBrightnessComboBox->addItem(testString2);
And yes, it does work! I'll append a screenshot. I guess you could go ahead and paste the characters themselves into your source code, but then you've gotta play around with saving and compiling non-ascii file formats...

Edit: yeah, it does look like Qt prefers pure ascii source files, as described in this article:

Occasionally it seems the simplest solution is just to insert those strings in their native form in the sources - this is unfortunately rarely a good solution. While the strings might look correct in an editor, the compiler and target platform might interpret them differently. The recommendation is thus to *always* avoid putting non-ASCII string is the sources.
Attached Images
 

Last edited by Copernicus; 2014-04-05 at 19:10. Reason: more info on ascii source files
 

The Following 5 Users Say Thank You to Copernicus For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#20
Thanks, Copernicus. After I've finally RTFM, I've found a solution that seems to work:

Name:  Screenshot-20140406-074033.jpg
Views: 178
Size:  21.0 KB

Code:
static void initMultipliersResistance(QComboBox *qcb)
{
    qcb->clear();
    qcb->addItem(QString::fromUtf8("Ω"), 1);
    qcb->addItem(QString::fromUtf8("kΩ"), 1e3);
    qcb->addItem(QString::fromUtf8("MΩ"), 1e6);
    qcb->addItem(QString::fromUtf8("GΩ"), 1e9);
    qcb->addItem(QString::fromUtf8("TΩ"), 1e12);
    qcb->setCurrentIndex(0);
}
However your solution looks safer so I think I'll go that way.
__________________
Русский военный корабль, иди нахуй!
 

The Following 3 Users Say Thank You to pichlo For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 22:37.