Skip to content

Language Bindings

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

  • 0 Votes
    2 Posts
    6k 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
    957 Views
    No one has replied
  • 0 Votes
    6 Posts
    11k 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.

  • Phonon with vlc backend on Windows

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Convert a code using PySide with Cython

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • Windows Store (aka Windows Metro), C#, and Qt

    6
    0 Votes
    6 Posts
    4k Views
    T

    No, stop myself and to work on another project.

    I mean if it goes swimmingly I would submit it for review but as Qt is widely adapted commercially I'd expect some kind of commercially employed people tasked to update it and merge into the public branch.

    To merge anything they have control over that anyway.

  • 0 Votes
    1 Posts
    996 Views
    No one has replied
  • 0 Votes
    4 Posts
    1k Views
    R

    I use python's eval() function solved it ! thanks all your replies !

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • QtWebKit and QHttpThreadDelegate

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    2 Posts
    7k Views
    P

    the solution is:

    @ def BtnClick(self):
    #on self.Btn Click create:
    '''Widget B'''
    inputDlg = WidgetB(self)
    inputDlg.show()
    if inputDlg.exec_():
    self.editor.acceptUserInput(inputDlg.userInput())@

    userInput being a getter in WidgetB
    acceptUserInput being a setter in WidgetA

    Other possible solution would be using global variable but you still need .exec_() to make it work.

  • How get handle of Qwidget Child with vb.net ?

    9
    0 Votes
    9 Posts
    6k Views
    G

    Hi,

    ther very first HIT from google:

    http://en.wikipedia.org/wiki/Microsoft_Active_Accessibility

    that describes what MS Accessibility is.
    I don't know what you want to do.
    I don't know why you want to do that.

    You can't send windows messages to Qt widgets. You wanted to access the widgets, that is possible via MSAA, the only way I know on windows (if you do not have Qt for that).

  • Beginner Question about QCalendarWidget

    2
    0 Votes
    2 Posts
    2k Views
    T

    https://qt-project.org/forums/viewthread/19738/ is a german thread from dino about this issue with a bit more feedback.