Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
850 Topics 3.3k Posts
  • Pain and insanity: Unicode filenames and Qt

    4
    0 Votes
    4 Posts
    4k Views
    T

    Lots of fixes in that area have gone into Qt4.8, are you using that (or newer) ?

    It might also be good to check what the encoding is of the file on your filesystem. If you use Windows, it likely is not utf8. If you use Linux, its a 50% chance being utf8 or some other encoding.

  • 0 Votes
    2 Posts
    1k Views
    B

    Subclass QWindow. Reimplement an event handler such as FocusInEvent(event.). In your reimplementation, call the super handler, and also do your print.

    There may be a better event to snoop on. Probably the FocusInEvent() (receive the focus of keyboard events) comes after the window is painted, but I'm just guessing.

  • 0 Votes
    2 Posts
    3k Views
    S

    Did you try the implementation provided "here":http://qt-project.org/forums/viewthread/23852/ as both the posts are same.

  • Integration of PyQt/PySide issue

    2
    0 Votes
    2 Posts
    2k Views
    I

    The problem was due to mismatch of Qt libs versions.
    After that we solved issues with incompatibility of libs that are coming along with Salome (sip) and those that were installed
    in the system.

    But we still have some issues: We cannot pack commercial PyQt with VendorID in the hidden library.
    If i get it right, there is a mention of this possibility in the oficial document "VendorID - Signing Python Interpreters and Modules"
    (p.3.1 Creating Restricted Extension Modules).

    To figure out how Vedor ID works i created foo.py script that contained couple of functions,
    1 class and also foomodule.c file (identical to the one in example Reference Guide 3.1 Creating Restricted Extension Modules)

    After that we tried to create a library with the help of commands:

    @> python ~/VendorID-1.0.0/sib/sib.py -u foo.py@

    the folder build_foo is created with files makefile, main.c, frozen.c in it

    @> make@

    And we got the next message in the terminal:
    @gcc -pthread -Xlinker -export-dynamic main.o foo.o frozen.o -o foo -lpthread -ldl -lutil -lm -L/usr/local/lib -lpython2.6
    /usr/local/lib/libpython2.6.a(dynload_shlib.o): In function
    _PyImport_GetDynLoadFunc': /home/modeller/Python-2.6.6/Python/dynload_shlib.c:94: undefined reference to dlsym'
    /home/modeller/Python-2.6.6/Python/dynload_shlib.c:130: undefined reference to dlopen' /home/modeller/Python-2.6.6/Python/dynload_shlib.c:141: undefined reference to dlsym'
    /home/modeller/Python-2.6.6/Python/dynload_shlib.c:133: undefined reference to dlerror' ... /home/modeller/Python-2.6.6/Objects/floatobject.c:972: undefined reference to pow'
    /usr/local/lib/libpython2.6.a(longobject.o): In function
    PyLong_FromString': /home/modeller/Python-2.6.6/Objects/longobject.c:1610: undefined reference to log'
    /home/modeller/Python-2.6.6/Objects/longobject.c:1610: undefined reference to `log'
    collect2: executing lt finished with return code 1
    make: *** [foo] Error 1@

    The issue with PySide still remains: PySide is referring to a lib that has to be located in the system folder /usr/lib/i386-linux-gnu/libpyside-python2.7.so, while in our case all paths should be relative.

  • Can anyone make a PyQt bindings of VLC-Qt ?

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Ubuntu: Failed update of PySide

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    5 Posts
    8k Views
    jazzycamelJ

    I am aware of the existence of QGesture, QGestureRecognizer etc., the example (and my Python port) probably predates this framework, I did create it sometime ago and only refreshed it in response to your original request for an example.

    In response to your subsequent request I have created an example with almost equivalent functionality using the newer methods. As before, it can be found on my blog "here":http://www.gulon.co.uk/2013/01/14/pyqt4-mouse-gestures-part-deux/.

  • C++ updating data to QML

    5
    0 Votes
    5 Posts
    7k Views
    W

    Do N3Roaster said. From "http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-exposecppattributes.html":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-exposecppattributes.html

    For maximum interoperability with QML, any property that is writable should have an associated NOTIFY signal that is emitted whenever the property value has changed.

  • QML/C++ bindings

    5
    0 Votes
    5 Posts
    7k Views
    W

    thanks, that was it!

  • PySide translations work just partially

    2
    0 Votes
    2 Posts
    2k Views
    J

    Yay! I finally managed to find the reason for the problem. Using a python multi-line text without indentation confuses the Qt translation system so that the following translations won't work. E.g.
    @

    def some_method(self):
    self.tr('This text gets translated correctly')

    def get_info(self):
    info_text = """<h1> My Program v. 1.0 </h1>
    <br>
    <br>
    This multi-line text is not meant to be translated, but it breaks the translations from the following tr() calls.
    """
    return info_text

    def another_method(self):
    self.tr('This text is not translated anymore because of the mutli-line text in method get_info.')
    @

    Should I add this issue to PySide bug tracker? (I don't have bug tracker account yet).

  • 0 Votes
    4 Posts
    3k Views
    P

    @redstoneleo,

    Post you solution if its solved. So it may help others.

  • List/TreeWidget vs. List/TreeView?

    2
    0 Votes
    2 Posts
    8k Views
    H

    Views works on model, widget versions works on inserted items.

    Read "Model View programming":http://qt-project.org/doc/qt-4.8/model-view-programming.html

  • Installing pyside and python 3.x

    2
    0 Votes
    2 Posts
    4k Views
    3

    Ok, so ... I finally got it to work. I ended up using
    @brew install pyside@

    Although there were a few things I still had to link up to make it work, overall it was not too painful. But now that I have it up and running I cant wait to try things out. :)

  • PyQT : are sprites available ?

    2
    0 Votes
    2 Posts
    2k Views
    D

    You could take a look at the Graphics View examples provided with PyQt to see if there's anything that looks like it might be useful.

  • 0 Votes
    3 Posts
    5k Views
    A

    This worked great! Thanks so much.

  • QtJambi: update Widget from a test

    2
    0 Votes
    2 Posts
    2k Views
    D

    call QApplication.processEvents(); before going to sleep() that should get you what you want, but it is not a good idea to ever wait/sleep during the startup sequence. This being the point between calling initialize() and exec().

    You want to call exec() as soon as possible to perform all other behaviour in response to eventing. So this means setting up the first state but never calling Thread.sleep() but using eventing instead.

    One way to do this maybe to make use of QObject.startTimer(int) to get a callback to the method QObject#timerEvent(QTimerEvent). So you subclass QObject and implement the @Override method and this replaces the Thread.sleep() usage with no need to ever call it.

    There are other Qt ways such as using a QTimer object and connecting the slot to a callback method of your choice that cycled through the states and changes UI, sets up QTimer for the next (or stops it) and immediately returns.

  • Memory Management in Qt/C++

    8
    0 Votes
    8 Posts
    4k Views
    G

    [quote author="Gerolf" date="1355228848"]e.g. in Main, you can create the widgets on the stack.
    If you have top level QObjects elsewhere where the stack is not possible, use smart pointers like shared pointers or others.[/quote]

    Hi Gerolf,

    Will you please give me some example related this to study because everything which is related to memory leak is going over my head. So it would be nice to have some example to go through and then decide how to about memory leaks.
  • Linking problem with C static Library

    4
    0 Votes
    4 Posts
    2k Views
    F

    What about the C-Library header file?

    You may need the 'external "C" {};' declaration for the methods provided in pure C like this:
    @
    #ifdef cplusplus
    external "C" {
    #endif

    void C_method1(void);

    #ifdef cplusplus
    };
    #endif
    @

  • 0 Votes
    3 Posts
    2k Views
    N

    Stupid error in my code where I, myself, on my own, disable my own widgets by setting inhibit_edit to True.
    Sigh...

    I need a bit of a lie down :)

  • How to Fullscreen the child widget

    3
    0 Votes
    3 Posts
    6k Views
    jazzycamelJ

    The following is a basic working example of what I think you're trying to do. It also hides the lower controls (sliders and buttons) in full screen mode like a media player would (just delete line 55 to prevent this):

    @
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *

    class BlackWidget(QWidget):

    doubleClick=pyqtSignal() def __init__(self, parent=None, **kwargs): QWidget.__init__(self, parent, **kwargs) def paintEvent(self, e): p=QPainter(self) p.fillRect(self.rect(), Qt.black) def mouseDoubleClickEvent(self, e): self.doubleClick.emit()

    class Widget(QWidget):
    def init(self, parent=None):
    QWidget.init(self, parent)

    self.resize(640,480) self._fullScreen=False l=QGridLayout(self) blackWidget=BlackWidget(self, doubleClick=self.changeScreenSize) l.addWidget(blackWidget, 0, 0, 1, 4) self._controls=[] slider1=QSlider(Qt.Horizontal, self) self._controls.append(slider1) l.addWidget(slider1, 1, 0, 1, 4) button1=QPushButton("Button 1", self) self._controls.append(button1) l.addWidget(button1, 2, 0) button2=QPushButton("Button 2", self) self._controls.append(button2) l.addWidget(button2, 2, 1) button3=QPushButton("Button 3", self) self._controls.append(button3) l.addWidget(button3, 2, 2) slider2=QSlider(Qt.Horizontal, self) self._controls.append(slider2) l.addWidget(slider2, 2, 3) @pyqtSlot() def changeScreenSize(self): self.showNormal() if self._fullScreen else self.showFullScreen() for c in self._controls: c.setVisible(self._fullScreen) self._fullScreen^=True

    if name=="main":
    from sys import argv, exit
    a=QApplication(argv)
    w=Widget()
    w.show()
    w.raise_()
    exit(a.exec_())
    @

    Hope this helps ;o)