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

Linux specific forum
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

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

Post 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?
Last edited by Kukulkan on Tue Jul 07, 2020 11:50 am, edited 1 time in total.
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post 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
quidquid Latine dictum sit altum videtur
User avatar
mk-soft
Always Here
Always Here
Posts: 5406
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

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

Post by Kukulkan »

Thanks! Both posts were helpful :-)
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post 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.
quidquid Latine dictum sit altum videtur
Post Reply