Page 1 of 1

[solved] How to activate line-wrap in EditorGadget() with QT

Posted: Mon Jul 06, 2020 4:57 pm
by Kukulkan
Hi,

using GTK I used

Code: Select all

gtk_text_view_set_wrap_mode_(GadgetID(Gadget.i), #GTK_WRAP_WORD)
to activate line-wrapping inside of an EditorGadget().

Now I need the same for QT. I tried with this:

Code: Select all

QtScript(~"gadget("+Str(Gadget.i)+~").setLineWrapMode(1);")
But I always get
[ERROR] JavaScript error: TypeError: Property 'setLineWrapMode' of object QTextEdit(0x20f3930) is not a function

I checked the QT documentation for QTextEdit class (link) but do not understand why this is not a function? Wrong gadget type?

Re: How to activate line-wrap in EditorGadget() with QT subs

Posted: Mon Jul 06, 2020 9:48 pm
by freak
If it is a property then it should be accessible like this:

Code: Select all

QtScript(~"gadget("+Str(Gadget.i)+~").lineWrapMode = 1;")
However, there is also a flag for the EditorGadget() which does the same in a cross-platform way: #PB_Editor_WordWrap

Re: How to activate line-wrap in EditorGadget() with QT subs

Posted: Mon Jul 06, 2020 11:44 pm
by mk-soft
Hello freak,

lineWrapMode is default on "1"
Only with flag #PB_EditorWordWrap we can change it with afterwards.

Code: Select all

Runtime Procedure QtSignalHandler()
  MessageRequester("", "Signal received!")
EndProcedure  

If OpenWindow(0, 0, 0, 320, 250, "FrameGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ;EditorGadget(0, 10,  10, 300, 230, #PB_Editor_WordWrap)
  EditorGadget(0, 10,  10, 300, 230)
  
  ; show the EditorGadget object's content
  Debug QtScript("dump(gadget(0))")
  
  Debug "**************"
  Debug QtScript("gadget(0).lineWrapMode")
  ;Debug QtScript("gadget(0).lineWrapMode = 1")
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: How to activate line-wrap in EditorGadget() with QT subs

Posted: Tue Jul 07, 2020 11:49 am
by Kukulkan
Thanks! Both posts were helpful :-)

Re: [solved] How to activate line-wrap in EditorGadget() wit

Posted: Tue Jul 07, 2020 6:16 pm
by freak
If you use #PB_Editor_WordWrap, we set a property called "wordWrapMode". Without setting this property to something other than 0 it seems like the "lineWrapMode" value is ignored. However, this property does not seem to be available in the scripting object. Don't ask me why.
https://doc.qt.io/qt-5/qtextedit.html#wordWrapMode-prop

You can change #PB_Editor_WordWrap also after creating the gadget with SetGadgetAttribute() as well btw.