Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
860 Topics 3.4k Posts
  • qtreeview, get mouse-selected-item into cell-editing

    Unsolved
    1
    0 Votes
    1 Posts
    515 Views
    No one has replied
  • Random exits code -1073741819 after switch to PySide2

    Solved
    3
    0 Votes
    3 Posts
    1k Views
    ewerybodyE

    I think I solved it!
    Although I didn't have a clue what caused it exactly I once just stepped through the whole thing and made some changes accordingly.

    Here is the commit that made my app work again.
    Basically made a widget in a tab page with some HTML content arranged in Qt Designer load on demand and not on startup right away.

    It mostly crashed when the translation kicked in on the setText like self.a2license_text.setText(QtWidgets.QApplication.translate( ...and here the HTML stuff ...

    And then I added some more on demand widget builds removing about 80 widgets from the startup. Probably better to have it as slim as possible anyway.

  • 0 Votes
    3 Posts
    2k Views
    ewerybodyE

    I dunno C++ well enough but this kind of stuff is surely possible. For instance Maya does it just the same way.
    Or actually Cryengine Sandbox! 😃
    Here is the code on github!

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • Some issues with QTextEdit (PySide2)

    Unsolved
    3
    0 Votes
    3 Posts
    887 Views
    K

    Hi, I encountered it when developing a simple app. I was able to deal with it somehow, thus this is meant as a notice about these issues for Qt people.

    The missing signaling on select-all event can be seen by commenting out self.highlight_current_line() at (one of) def selection_changed(self): there.

    The issue with line highlighting of right-aligned lines can be seen by adding self.setAlignment(QtCore.Qt.AlignRight) at one of the QTextEdit-based classes, like at class CmdTextEdit(QTextEdit): e.g. just before self.setUndoRedoEnabled(True) by the end of its __init__:

    self.setAlignment(QtCore.Qt.AlignRight)
    self.document().setModified(False)
    self.setUndoRedoEnabled(True)

    with the self.document().setModified(False) being put there to convince Qt that this setting is still within initialization.

    BTW I've seen at the Qt example that line numbers are thought to be drawn by painters, though the painter did not want to work for me (complaining about something, may be about being not active, not sure now). And since I did not know how to convert that example onto partially-seen lines anyway, I did it a different way.

  • 0 Votes
    7 Posts
    5k Views
    SGaistS

    It's essentially the same, most of the time you have some translation to do from one language to the other, but the logic is exactly the same.

  • Qtextdit format A4

    Unsolved
    1
    0 Votes
    1 Posts
    538 Views
    No one has replied
  • Advanced design techniques

    3
    0 Votes
    3 Posts
    760 Views
    I

    Thank you! Second example is really what I wanted!

  • Runing a .exe inside a form

    Unsolved
    2
    0 Votes
    2 Posts
    811 Views
    _

    Hi HugoMandes,

    see the Qt-Documentation -> http://doc.qt.io/qt-5/qprocess.html
    It's also possible to get the window handle from the Qt Widget (http://doc.qt.io/qt-5/qwidget.html#winId).

    But in the past I want to embedded the Microsoft Excel inside the Qt application and this not work very well. I think it's easier to use only the microsoft eco system if possible - or a work around before embedding/drawing/event-handling a application inside a Qt application.

    Regards,
    Jakob

  • 0 Votes
    3 Posts
    2k Views
    H

    @SGaist said in Qtreeview &QSortFilterProxyModel, select/scroll/expand to entry (pyqt5):

    mapFromSource

    Thanks for your answer!
    While I was so sure, I had tried it already, obviously I had not.... It now works.!

    Thanks a lot!!

  • how to create custom style class on PyQt4 / PyQt5

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    J

    @SGaist thx for the hint. Will look into it

  • trying to open .so with QLibrary

    Unsolved
    2
    0 Votes
    2 Posts
    783 Views
    SGaistS

    Hi and welcome to devnet,

    Are you sure you library can be found ?

    What version of Qt are you using ?
    On what platform ?

  • qtreeview select single item & column

    Solved
    3
    0 Votes
    3 Posts
    3k Views
    H

    Thanks a lot for the hints!

    I had tried these without success but your input triggered me to look further in this direction and I discovered something called selectionbehavior.

    In pyqt5 I use:
    self.view.setSelectionBehavior(QAbstractItemView.SelectItems)

    Thanks again!

  • 0 Votes
    3 Posts
    1k Views
    H

    Great, I had missed that....
    I simply could not believe that it is actually that easy...

    Thanks a lot!

  • qmake fine tuning

    Solved
    2
    0 Votes
    2 Posts
    653 Views
    Stanislav SilnickiS

    @Stanislav-Silnicki long story short: i did it.

    write correct targets interdependency in .pro: #------------------------------------------------- # # Project created by QtCreator 2018-04-02T04:41:55 # #------------------------------------------------- QT -= core gui TARGET = andy TEMPLATE = lib DEFINES += ANDROID_ANDY_LIB_LIBRARY SOURCES += \ andy_native.cpp HEADERS += \ com_andy_EartActivity.h \ andy_native.h firsttarget.target = firsttarget firsttarget.commands += javac -cp /home/user/Android/platforms/android-26/android.jar:/home/user/Unity-2018.1.0b8/Editor/Data/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Classes/classes.jar -sourcepath java/src java/src/com/andy/AndyActivity.java -d java/classes secondtarget.target = secondtarget secondtarget.commands = javah -cp java/src com.andy.AndyActivity lasttarget.target = lasttarget lasttarget.commands = jar cvfM andy.jar -C java/classes . libandy.so QMAKE_EXTRA_TARGETS = firsttarget secondtarget lasttarget PRE_TARGETDEPS = firsttarget secondtarget DISTFILES += \ java/src/com/andy/AndyActivity.java

    this will produce first three targets while in first make invocation.

    Than, the last forth target (.jar) has to be built during second make invocation, that is added via QtCreators menu:

    0_1522691307624_Screenshot from 2018-04-02 20-47-48.png

    note, last two default build steps in QtCreators menu are disabled. This saves compile time. It just adds no value to my goal.

    We are the champions! ))

    UPDATE: just couple sidenotes for those, who stucks in android's development like I constantly do:

    a) packing native libYourNativeLib.so in java's .jar will make it hard to init... so, finally I refused this approach and just left binary lib for deployment as a separate file.
    b) if your Android app will crush due to inability to load gnustl_shared, just add this line in qmake's .pro:

    QMAKE_LIBS_PRIVATE -= -lgnustl_shared
  • Pyside2 5.9 Branch/QT 5.8/GCC 6.4/Linux - Build Failure

    Unsolved
    2
    1 Votes
    2 Posts
    918 Views
    H

    I had the same error with gcc 7.3. I ended up just using clang for compiling as that seemed to work:
    CC=clang CXX=clang++ python setup.py build --qmake=/usr/bin/qmake-qt5 --ignore-git --build-tests --jobs=8

  • PySide Signals not being sent to Slot, from QThread object.

    Unsolved
    2
    0 Votes
    2 Posts
    683 Views
    SGaistS

    Hi and welcome to devnet,

    There's no event loop running at all. Therefore signals and slots won't be working.

  • python-pyqt5

    Unsolved
    1
    0 Votes
    1 Posts
    735 Views
    No one has replied
  • singleton in python, with qobject

    Solved
    2
    0 Votes
    2 Posts
    4k Views
    jazzycamelJ

    The following is my implementation (and a usage example) of a singleton I use regularly:

    try: from PyQt5.QtCore import pyqtWrapperType except ImportError: from sip import wrappertype as pyqtWrapperType class Singleton(pyqtWrapperType, type): def __init__(cls, name, bases, dict): super().__init__(name, bases, dict) cls.instance=None def __call__(cls,*args,**kw): if cls.instance is None: cls.instance=super().__call__(*args, **kw) return cls.instance if __name__=="__main__": from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty class MyObject(QObject, metaclass=Singleton): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._x=0 def x(self): return self._x @pyqtSlot(int) def setX(self, x): self._x=x x=pyqtProperty(int, x, setX) print(MyObject().x) MyObject().x=1 print(MyObject().x)

    I've actually shared this example/technique so many times now that I just quickly created a git repo (https://github.com/jazzycamel/PyQt5Singleton) and a PyPi package (https://pypi.python.org/pypi/PyQt5Singleton) so you can just install it via pip:

    $ pip install PyQt5Singleton

    and use it (as above):

    from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty from PyQt5Singleton import Singleton class MyObject(QObject, metaclass=Singleton): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._x=0 def x(self): return self._x @pyqtSlot(int) def setX(self, x): self._x=x x=pyqtProperty(int, x, setX) if __name__=="__main__": print(MyObject().x) MyObject().x=1 print(MyObject().x)

    Hope this helps :)

  • 0 Votes
    8 Posts
    3k Views
    aha_1980A

    @CLang

    I now tried your example with HTML: it would look like this:

    QString plotYAxis = tr("Emission Factor(g/m<sup>2</sup>h)");

    and I got this nicely rendered on a QLabel.