Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
850 Topics 3.3k Posts
  • 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
    741 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
    627 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
    867 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
    651 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
    696 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.

  • too many positional arguments for constructor call

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    U

    found out the reason. it should be window_flags=Qt.WindowFlags(), not window_flags=None

  • check for non valid object

    Solved
    2
    0 Votes
    2 Posts
    624 Views
    JonBJ

    @user4592357
    And do what if it isn't? You're only going to raise, and self.mw.addDockWidget will raise anyway if it isn't. Plus self.mw = QMainWindow() would have raised in the first place if it couldn't create a main window.

    Of course you can check everywhere if you wish. But that can be a lot of code. I wouldn't bother here.

    P.S.
    Unless you're doing it for a school project. In which case, goodness knows...

  • PyQt5 closeEvent reimplementation

    Solved
    20
    0 Votes
    20 Posts
    13k Views
    SGaistS

    In the python case, that's indeed something debatable. Most of the time, people don't need to implement __del__.

    What I would do is to store the settings once you close the corresponding dialog so that you avoid the trouble you had with the unintended interruption you have (unless it's done while the dialog is open).

    In the extreme case, you can even save you settings on modification if you have an "apply immediately" without cancel style of application preferences.

  • initializing an attribute in __init__

    Solved
    10
    0 Votes
    10 Posts
    3k Views
    SGaistS

    No it's not.

    See this excellent article from Arne Mertz on the subject.

  • 0 Votes
    4 Posts
    1k Views
    SGaistS

    Same as before except that you will have two Q_SIGNAL in the connect statement if using the old version.

  • insert text to textbox and..

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    Pablo J. RoginaP

    @Dl10 said in insert text to textbox and..:

    I managed to thank you all !

    it looks like you have solved your problem, so two things please: write a reply showing how you actually solved it :-) and two, don't forget to mark you post as solved. Thanks.

  • QTableView row selection highlight pyside2 issue

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    mrjjM

    Ok. i cant find any other reporting that issue.
    You could look in https://bugreports.qt.io
    If you can reproduce it with a minimal example, then open bug report.

  • Python/PyQt freeing of objects

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    JonBJ

    @SGaist
    Great stuff --- I'll study that link.

  • 0 Votes
    55 Posts
    16k Views
    JonBJ

    @Xenoshell
    There is literally like one occurrence on the whole of the Interweb of your error in vainfo (va_openDriver() returns -1)!
    https://bugs.launchpad.net/ubuntu/+source/libva-utils/+bug/1719150
    It was suggested:

    Please install mesa-va-drivers and try gain.

    I suggest you try that.... :)

  • Convert .ui to .py file?

    Moved Unsolved
    5
    0 Votes
    5 Posts
    12k Views
    JonBJ

    @Ken_Du
    I use PyCharm as my Python/PyQt IDE, and I shan't be moving off that. But OOI does your eric really do much other than allow you to convert .ui to .py, which I see I can do via PyQt's pyuic5?