Skip to content

Language Bindings

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

  • 0 Votes
    2 Posts
    5k Views
    jazzycamelJ

    I'm afraid I can't repeat your problem using your code on any of my systems (Mac, Windows7 or Linux), the dialog always comes up centered irrespective of the MainWindow state. What's your setup? You could try setting the dialog's parent to the MainWindow (i.e. QMessageBox(self)), its generally good practice and a good idea to give widgets a parent.

    As a more general answer to your question, the following example demonstrates centering a dialog on the screen:

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

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

    size=self.size() desktopSize=QDesktopWidget().screenGeometry() top=(desktopSize.height()/2)-(size.height()/2) left=(desktopSize.width()/2)-(size.width()/2) self.move(left, top)

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

    This will work for any QWidget derivative.

  • RFC Update Wiki Qt_Jambi entry

    1
    0 Votes
    1 Posts
    931 Views
    No one has replied
  • 0 Votes
    6 Posts
    10k Views
    jazzycamelJ

    How are you updating the QLabel? You will need to use signal/slot to communicate between the shared memory thread and the main thread...

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

    class Thread(QThread):
    update=pyqtSignal(str)
    def init(self, parent=None):
    QThread.init(self, parent)
    self.count=0

    def run(self): self.tid=self.startTimer(1000) self.exec_() def timerEvent(self, event): self.count+=1 if self.count==10: self.killTimer(self.tid) self.exit(0) self.update.emit("%d" % self.count)

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

    l=QVBoxLayout(self) self.label=QLabel("0", self) l.addWidget(self.label) self.thread=Thread(self) self.thread.update.connect(self.label.setText) self.thread.start()

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

    This example works fine without any warning messages.