Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent text wrapping in QPlainTextEdit? #82

Closed
jameshibbard opened this issue Sep 4, 2019 · 14 comments
Closed

How to prevent text wrapping in QPlainTextEdit? #82

jameshibbard opened this issue Sep 4, 2019 · 14 comments
Labels
enhancement New feature or request

Comments

@jameshibbard
Copy link
Contributor

jameshibbard commented Sep 4, 2019

I have a QPlainTextEdit on which I wish to display a random combination of letters, numbers and special characters (a password, basically).

When the text is only letters and numbers, the output runs from left to right with no breaks (as one would expect). It only wraps when it hits the edge of the QPlainTextEdit.

passOutput.setPlainText(
  'AS0dlkqVDmC5L8mKhNAmVU7Ww2j9LiCFo6k43uR6lngZ0Prr2I1xRF7Y64PF92j87V'
);

qode_001

However, if the text contains certain special characters an undesired line break is inserted. E.g.:

passOutput.setPlainText(
  '2VB#t>ZQyS.*|t`=t=AdB=s9gyNKt%Up9q:fKpL]DKB-5:g),cneAg4(bH:A9hF/cH'
);

qode_002

Notice the line break after the | character.

My question: is there any way to prevent this?

I would like the text containing the special characters to run from left to right and only wrap when the edge of the QPlainTextEdit is reached (like the example containing just letters and numbers).

I tried styling the QPlainTextEdit using word-break: break-all, but it didn't make a difference.

Looking through the QT docs, I did find this: https://doc.qt.io/qt-5/qtextoption.html#WrapMode-enum

Is something like wrap mode available in NodeGUI?

@a7ul
Copy link
Collaborator

a7ul commented Sep 5, 2019

Hey @jameshibbard I have a pull request addressing your requirements here. This will be available in the next release.

@jameshibbard
Copy link
Contributor Author

Thank you @master-atul! I really appreciate the quick response and look forward to the next release.

There are two remaining things which I still need to implement in my app. I would have opened issues to ask about the best way of implementing them, but I'll mention them here, as maybe there's a chance that one or the other of them also makes the next release.

  1. I'd like the ability to set the title of the window. As you can see from the screenshots above, it is qode by default. I'd like to set it to be something different. I've tried the widget.setWindowTitle() method, but it didn't work (the window title remained unchanged). Is it possible that it hasn't been implemented yet?

  2. I'd like to implement a "Copy to Clipboard" function. Would this be the QClipboard Class in QT?

Once again, thanks for your help. When I'm done building this demo app, I'm intending to write a tutorial demonstrating how to make a password generator with NodeGUI. I'd love to help get the word out about this library!

@a7ul
Copy link
Collaborator

a7ul commented Sep 5, 2019

Hi @jameshibbard

  1. You can call setWindowTitle from window instance and that should work as expected.

  2. Awesome, I ll see if I can push the QClipboard class also in this release otherwise it would be in the next.

Also, if its not too much to ask, once you are done writing your app can you provide me a link to it so that I can mention it in the Readme or examples of this project. 😄

@jameshibbard
Copy link
Contributor Author

jameshibbard commented Sep 5, 2019

  1. Oh nice. That didn't work last time I checked, but all good now 😄

  2. Thank you!! Any idea when the next release will be?

Also, if its not too much to ask, once you are done writing your app can you provide me a link to it so that I can mention it in the Readme or examples of this project.

Absolutely. I can also provide you a link to the tutorial if that helps.

@a7ul
Copy link
Collaborator

a7ul commented Sep 5, 2019

Hi @jameshibbard the next release would be this weekend (probably saturday)

@a7ul a7ul added the enhancement New feature or request label Sep 7, 2019
@a7ul
Copy link
Collaborator

a7ul commented Sep 7, 2019

v0.1.8 is out! 🎉 https://github.com/nodegui/nodegui/releases/tag/v0.1.8

@a7ul a7ul closed this as completed Sep 8, 2019
@jameshibbard
Copy link
Contributor Author

Everything works like a charm. Thank you!!
I'll get the demo app finished in the next couple of days and send you a link.

@a7ul
Copy link
Collaborator

a7ul commented Sep 8, 2019

Awesome 😁😁

@jameshibbard
Copy link
Contributor Author

jameshibbard commented Sep 9, 2019

Here ya go: https://github.com/jameshibbard/nodegui-password-generator

If there's anything about the code that could be improved, please let me know.

@a7ul
Copy link
Collaborator

a7ul commented Sep 9, 2019

Awesome!! Thanks @jameshibbard
I will add a link to this in the README :) If you manage to write a tutorial for this I will link it too once you have posted

@jameshibbard
Copy link
Contributor Author

jameshibbard commented Sep 9, 2019

No worries. Will might take a couple of weeks, but I will a) definitely write this, and b) keep you posted 😄

@jameshibbard
Copy link
Contributor Author

jameshibbard commented Sep 28, 2019

Hey @master-atul, I got the tutorial done. You can find it here: https://hibbard.eu/node-gui/

Grateful for any feedback, esp. if anything can be improved.

@a7ul
Copy link
Collaborator

a7ul commented Sep 30, 2019

Thanks @jameshibbard. The blog is really nicely written and represents the project accurately. I have added the link on the README :) Cheers.

@jameshibbard
Copy link
Contributor Author

Happy to help. Thanks for the link in the README :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants