Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
853 Topics 3.3k Posts
  • 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)

  • [SOLVED]Login dialog ?

    10
    0 Votes
    10 Posts
    6k Views
    Y

    c++ using qt.

  • QPalette VS stylesheet

    2
    0 Votes
    2 Posts
    3k Views
    R

    Stylesheets are usually quicker/simpler to use and offer more control than QPalette.
    In the future, could you please not write your questions in that SMS style but in plain old English? This will for sure help you get some answers. At first I did not even want to reply since your post was so hurtful to read.

  • PySide: How to get Back button in QWizard?

    3
    0 Votes
    3 Posts
    3k Views
    A

    There is a back button in Aero style, only it is shaped like a blue round arrow at the top left of the wizard. That is just how it is done in Aero...

  • 0 Votes
    2 Posts
    4k Views
    T

    I figured it out. I forgot to specify the slot's argument type. Fixed it by changing the slot's declaration to this:

    @@QtCore.Slot('QString')
    def printText(self,text):
    print text@

  • [PyQt] Fingerprint Reader Integration

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    4 Posts
    2k Views
    C

    [quote author="daniel__" date="1353055182"]i'm gonna think that i can't use views in shared library
    i really need help
    :([/quote]
    First, you need to create QAplication. Next don't call QApplication::exec in dll because will block host application events. Instead call QApplication::processEvents periodically (e.g. in some timer function)

  • 0 Votes
    7 Posts
    12k Views
    A

    jazzycamel -- thank you for all of you help. You have answered all of my questions with clarity and I appreciate it immensely.

    I have gone through the zetcode tutorials and find them very helpful (they're the only reason I've been able to get as far as I have), but whenever I've tried to do something a bit outside of the tutorial's scope, it's taken a lot of trial and error.

    At first I found the nokia documentation a bit overwhelming, but as I'm starting to develop an understanding of the syntax, the docs make more sense to me.

    Thanks again for all your help!

  • 0 Votes
    2 Posts
    3k Views
    jazzycamelJ

    You could do this using style sheets to get a static height, however the following method shows how to have the tab bar dynamically size to the text by inserting QLabels:

    @
    from PyQt4.QtGui import *

    class TabWidget(QTabWidget):
    def addTab(self, widget, text):
    i=QTabWidget.addTab(self, widget, "")
    self.tabBar().setTabButton(i, QTabBar.LeftSide, QLabel(text, self))

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

    l=QVBoxLayout(self) t=TabWidget(self) t.addTab(QWidget(self), "Tab\n1") t.addTab(QWidget(self), "Tab 2") t.addTab(QWidget(self), "Tab\n3") l.addWidget(t)

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

    Hope this helps.

  • Basic Implementation of Scroll Area in PyQt4

    3
    0 Votes
    3 Posts
    12k Views
    A

    Sorry I didn't respond earlier -- yes, this was very helpful. Much appreciated!

  • Memory leak when using PySide instead of PyQt

    2
    0 Votes
    2 Posts
    4k Views
    A

    I think this is not the problem with pyqtgraph, please see this,
    "reply from pyqtgraph maintainer":https://groups.google.com/forum/?fromgroups=#!topic/pyqtgraph/3LcTnVRKcbo

  • PySide QGLBuffer allocate input data

    2
    0 Votes
    2 Posts
    1k Views
    I

    It seems I found solution. We should use python modules like struct or array. For example:

    @from array import *

    points = [0.5, 1, -0.5]
    data = array('f', points)

    data.tostring() - returns packed data with size of len(data.tostring())@
  • 0 Votes
    2 Posts
    1k Views
    I

    Check the code that write your settings. Settings are "tree" like structure. Group is a node, settings are leaves. If you execute .beginGroup() - you are inside "MainWindow", when you execute .endGroup() you leave this node and are on the level before "MainWindow" and can read settings on this level or open groups there.
    Your code reads 2 settings from "MainWindow" group which should be on main level. If you change to .ini file settings your ini file should look like
    @[MainWindow]
    size=nnn
    pos=mmm@

  • 0 Votes
    2 Posts
    2k Views
    jazzycamelJ

    The following example probably does what you want. If you want to remember the choice for the future, use [[doc:QSettings]].

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

    class Dialog(QDialog):
    def init(self, parent=None):
    QDialog.init(self, parent)

    l=QVBoxLayout(self) l.addWidget(QLabel("A nice little dialog", self)) self.dontShowCBox=QCheckBox("Don't show this dialog again") l.addWidget(self.dontShowCBox) l.addWidget(QDialogButtonBox( QDialogButtonBox.Ok|QDialogButtonBox.Cancel, parent=self, accepted=self.accept, rejected=self.reject)) @staticmethod def dialog(parent): d=Dialog(parent) if d.exec_(): return True, not d.dontShowCBox.isChecked() else: return False, False

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

    self._prompt=True l=QVBoxLayout(self) l.addWidget(QPushButton("Button", self, clicked=self.dialogRequested)) @pyqtSlot() def dialogRequested(self): if not self._prompt: return ok, prompt=Dialog.dialog(self) if ok: self._prompt=prompt

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

  • 0 Votes
    2 Posts
    2k Views
    jazzycamelJ

    I'm not an expert in the use of Designer but AFAIK, you can't. You can write a widget with the functionality you want and expose it to designer (Put a normal QTextEdit in you UI form and then use the promote to... option, I've only done this in C++).

    IMHO, Designer and forms are only good for simple UI's where you don't want to modify standard behaviors, just connect to signals and slots and call methods on the created objects. I hardly ever use it preferring to layout all my UI's in pure python (or C++) as you have much finer control and better access to the objects you're creating. As I say, this is only my opinion. In your case, it will probably be simpler and quicker to do this.

  • How to implement key press events ?

    2
    0 Votes
    2 Posts
    7k Views
    jazzycamelJ

    You're right, you are going to have issues with focus if you re-implement keyPressEvent for each button. The example below uses QAction's bound to the widget to capture the key events. The buttons then simply invoke these actions "triggered" method.

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

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

    l=QVBoxLayout(self) self.label=QLabel("(None)", self) l.addWidget(self.label) self.setEnterAction=QAction("Set Enter", self, shortcut=Qt.Key_Return, triggered=self.setEnter) self.addAction(self.setEnterAction) l.addWidget(QPushButton("Enter", self, clicked=self.setEnterAction.triggered)) self.setSpaceAction=QAction("Set Space", self, shortcut=Qt.Key_Space, triggered=self.setSpace) self.addAction(self.setSpaceAction) l.addWidget(QPushButton("Space", self, clicked=self.setSpaceAction.triggered)) def setEnter(self): self.label.setText("Enter") def setSpace(self): self.label.setText("Space")

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

    Hope this helps.

  • 0 Votes
    7 Posts
    10k Views
    M

    Please Edit your Question and prepend /append [Solved] to it.

    Thanks & Regards..

  • 0 Votes
    2 Posts
    3k Views
    jazzycamelJ

    Another option is "OpenCV":http://opencv.willowgarage.com/documentation/python/index.html which I have used with good results, mainly as a way to capture images of QR and Bar codes.