Recent

Author Topic: Debug Qt5 Lib  (Read 341 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1211
    • tomboy-ng, a rewrite of the classic Tomboy
Debug Qt5 Lib
« on: October 12, 2020, 09:03:17 am »
I would really like some advice here.  I have been chasing a bug in RichMemo and have come up against what appears a problem in the bindings. Or the libraries them selves ? Both very unlikely but ...

Qt provides the QtextEdit widget, RichMemo does use it but I am pretty sure my problem is in the Qt system, not Richmemo.  QtextEdit has members that returns information about a specific char in the control's text. These methods are exposed to us FPC/Lazarus users as things like QTextEdit_textBackgroundColor(). All good.

If you open the control, for example in a RichMemo and type some text in or append a string, the control gives it sensible default colours, font etc. But if you try and find out what those settings are, bad luck, you get blank font, zero points and both foreground and background are black.

But if you manually set (eg) the colours, and then read them, you get what you would expect. So, the only way to read the settings in a control like this is to watch every key stroke and set its settings as the user types !  Thats not going to work !

Very simple demo attached, it has a RichMemo, it appends some text, tries to read the colours of that text. And fails. Then it sets some of that text's colours and tries again, it works.

Now, the QTextEdit_textBackgroundColor() method is defined in libQt5Pas, it just sets a passed var to the value returned by a call to QTextEdit.textBackgroundColor(), a function that exists, I believe in the Qt5 runtime libraries.  Can anyone suggest how I can debug that side of things ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

zeljko

  • Hero Member
  • *****
  • Posts: 1150
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Debug Qt5 Lib
« Reply #1 on: October 12, 2020, 10:09:45 am »
Stepping through code normally opens binding c code and Qt5 code when it's called. You must install dev packages for Qt5Pas bindings and Qt5 libraries so it should work (it works here, Fedora 29 64bit).

dbannon

  • Hero Member
  • *****
  • Posts: 1211
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Debug Qt5 Lib
« Reply #2 on: October 12, 2020, 12:14:46 pm »
Hmm, I have libqt5pas-dev installed.

And I have the qt5 libraries but not qt5 dev libraries.  But I don't think there are such things are here ?

But no, it does not step into the cpp code, I have never seen that happen.  Do you mean from within the Lazarus IDE or using gdb externally ?

Thanks !

Davo


Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

dbannon

  • Hero Member
  • *****
  • Posts: 1211
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Debug Qt5 Lib
« Reply #3 on: October 12, 2020, 01:44:56 pm »
Actually, zeljko, my libQt5Pas is stripped, no debugging symbols. Should I rebuild a new one with all the debugging in place ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

zeljko

  • Hero Member
  • *****
  • Posts: 1150
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Debug Qt5 Lib
« Reply #4 on: October 13, 2020, 11:09:22 am »
Actually, zeljko, my libQt5Pas is stripped, no debugging symbols. Should I rebuild a new one with all the debugging in place ?

Davo

That's actual problem. You should rebuild libQt5Pas with debug symbols and then you'll get stepping into cpp code.
Stepping works inside ide (even for cpp files)

 

TinyPortal © 2005-2018