Skip to content

Language Bindings

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

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

  • Pyside - Moving data between two list views

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    4 Posts
    7k Views
    N

    Thanks so much, jazzycamel! :)

    That worked great!!!

  • Put C++ class into QML window

    4
    0 Votes
    4 Posts
    2k Views
    S

    I try to achieve ability of dynamic qml object's creation from C++ code. I need create some objects from C++ code and then show them as part of main.qml
    I tried to replace QDeclarativeView on

    @ QDeclarativeEngine engine;
    QDeclarativeComponent component(&engine,
    QUrl::fromLocalFile("qml/PlanetWars/BaseObject.qml"));
    QObject *object = component.create();@

    but observe only RuntimeError.

  • QtCore.QAbstractItemModel

    3
    0 Votes
    3 Posts
    2k Views
    D

    Hi! Can you post your index() method's realization, please? Right now I have issues with this. I try to pass COM object to createIndex() as ptr parameter, but Python interpreter just crashes. Here is my index() method:
    @
    def index(self, row, column, parent=QtCore.QModelIndex()):
    if parent.isValid():
    parent_item = parent.internalPointer()
    try:
    child = parent_item.ChildRows[row]
    except:
    return QtCore.QModelIndex()
    else:
    try:
    child = self.card.Sections(self.card.Type.AllSections.
    GetByAlias('Main').ID).Rows[row]
    except:
    return QtCore.QModelIndex()
    return self.createIndex(row, column, child)@

    self.card - is the COM object. I use win32com library for working with COM. Interpreter crashes when trying to execute this:
    @return self.createIndex(row, column, child)@

    Thanks!

  • 0 Votes
    3 Posts
    2k Views
    E

    sorry Andre, i will try to explain better now.

    the problem is: Why calling QSqlTableModel.removeRow() erase the row content in the view and model. (so, calling record.field().value().toString() for the removed row --without calling submitAll()-- returns empty string for all fields.!!)

    doing so with PyQt v4.8.5 will keep the row contents untouched until i call submitAll() for actual deletion.

    Thanks for your patience.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • Error related to QConnection

    Locked
    2
    0 Votes
    2 Posts
    1k Views
    K

    welcome to devnet

    There is no need for "double posting":http://qt-project.org/forums/viewthread/19247/ on devnet.
    Threads may be moved by moderators if required.

    I am closing this thread because of double posting.