Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
853 Topics 3.3k Posts
  • 0 Votes
    8 Posts
    8k Views
    N

    Solved. See this "post":http://forums.cgsociety.org/showthread.php?p=7378920#post7378920.

  • PySide newbie question

    7
    0 Votes
    7 Posts
    5k Views
    F

    Yes, that was it, thanks a lot.

    I am still confused, and start on the tutorial again.

  • PySide compile from source on Windows 7 64-bit

    3
    0 Votes
    3 Posts
    3k Views
    R

    Maybe this
    "recipe":http://pypi.python.org/pypi/PySide/1.1.1qt474#installing-pyside-from-source-on-a-windows-system
    is what is needed.
    Owen

  • Fortran and Qt

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

    Hello all,
    The problem has morphed again.

    Question: Where should I look for generatorrunner on Win7? Should a pointer to it come back from PySideConfig.cmake?

    Details:

    From the Qt SDK I had both 4.8.0 and 4.8.1 libs installed and this was causing an issue, so I now have just the 4.8.0 MSVC 2008 environment.
    Now the error relates to

    @CMake Error at CMakeLists.txt:14 (message):
    You need to specify GENERATOR variable (-DGENERATOR=value)@

    It seems that generatorrunner is a command that you can run in a linux terminal, but I have no path to it on Win7. I think it should be part of pyside distribution, but I have found no files named generatorrunner on my whole Win7 drive.

    The message arises here in the CMakeLists.txt provided with the tutorial.
    @
    find_program(GENERATOR generatorrunner REQUIRED)
    if (NOT GENERATOR)
    message(FATAL_ERROR "You need to specify GENERATOR variable (-DGENERATOR=value)")
    endif()
    @

    apt-file search generatorrunner on linux gives
    shiboken: /usr/lib/i386-linux-gnu/generatorrunner/shiboken.so

    My Win7 build strategy for the binding tutorial is to launch a bare console then run:
    @
    CALL "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
    set QTDIR=C:\QtSDK\Desktop\Qt\4.8.0\msvc2008
    set PATH=%QTDIR%\bin;C:\QtSDK\QtCreator\bin;%PATH%
    set QMAKESPEC=win32-msvc2008
    set BINDFOO=C:\binding-tutorial\

    set Shiboken_DIR=.
    set PySide_DIR=.

    cd %BINDFOO%\libfoo
    qmake
    nmake

    cd %BINDFOO%\foobinding-cmake\build
    C:\CMake28\bin\cmake.exe ..
    @

    Thanks for any suggestions.

    Owen

  • [SOLVED]QAbstractProxyModel and mapToSource

    2
    0 Votes
    2 Posts
    2k Views
    I

    This function correctly fetches row and column numbers from the model, through a proxy:

    @def clickedSlot(self, modelIndex):
    model = modelIndex.model()
    if hasattr(model, 'mapToSource'):
    # We are a proxy model
    modelIndex = model.mapToSource(modelIndex)
    print modelIndex.row(), modelIndex.column()@

  • [PySide] QGraphicsItemGroup not visible

    3
    0 Votes
    3 Posts
    2k Views
    T

    Hi,

    I can confirm it :) . Your code does not work here with PySide. Shame.

    I'll contact the PySide guys.

    Thanks for your efforts :)

  • [PyQt4] -- Visual display of a register

    2
    0 Votes
    2 Posts
    3k Views
    jazzycamelJ

    Hi Olivier,

    I don't know if you managed to solve this already but if not I think the following example should do what you need. I wrote it for a project of my own with similar requirements and uses a custom QWidget with mouse events rather than a table or checkboxes. You can use the value() and setValue() functions to get and set the value programatically or click on the individual bits to toggle there values. Hope you find it useful, here goes:

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

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

    self.num_of_bits=num_of_bits self.data=[0 for b in range(num_of_bits)] self.data[1]=1 self.box_size=30 self.font=QFont('Serif', 12, QFont.Light) def setBoxSize(self, size): self.box_size=size def setFont(self, font): self.font=font def sizeHint(self): return QSize(self.num_of_bits*self.box_size, self.box_size) def paintEvent(self, event): painter=QPainter() painter.begin(self) painter.setFont(self.font) size=self.size() width=size.width()-1 height=size.height()-1 for i,v in enumerate(self.data): painter.fillRect(i*self.box_size, 0, self.box_size, self.box_size, Qt.green if self.data[i] else Qt.red) painter.drawLine(i*self.box_size, 0, i*self.box_size, height) valueString="%d" % i fontWidth=painter.fontMetrics().width(valueString) fontHeight=painter.fontMetrics().height() painter.drawText((i*self.box_size)-(fontWidth/2)+(self.box_size/2), (self.box_size/2)+(fontHeight/2), valueString) painter.setPen(Qt.black) painter.drawRect(0, 0, width, height) painter.end() def mousePressEvent(self, event): b=event.pos().x()//self.box_size self.data[b]^=1 self.repaint() event.accept() def value(self): value=0 mask=1 for i,v in enumerate(self.data): if v: value|=mask mask<<=1 return value def setValue(self, value): mask=1 for i,v in enumerate(self.data): self.data[i]=(value&mask)>>i mask<<=1 self.repaint()

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

    QVBoxLayout(self) self.bitWidget=BitWidget(16, self) self.layout().addWidget(self.bitWidget) valueButton=QPushButton("Value", self) valueButton.clicked.connect(self.printValue) self.layout().addWidget(valueButton) self.valueSpinBox=QSpinBox(self) self.valueSpinBox.setRange(0, 2**16) self.layout().addWidget(self.valueSpinBox) setValueButton=QPushButton("Set Value", self) setValueButton.clicked.connect(self.setValue) self.layout().addWidget(setValueButton) def printValue(self): print "Value:", self.bitWidget.value() def setValue(self): self.bitWidget.setValue(self.valueSpinBox.value())

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

    It should look something like this:

    !http://s15.postimage.org/r3nwtauor/bitwidget.png(BitWidget Screenshot)!

    Feel free to ask any questions, hope it helps.

    Rob

  • [Solved] Python QPixmap positioning?

    4
    0 Votes
    4 Posts
    6k Views
    N

    Thanks again, jazzycamel!!! :)

  • [Solved] PyQt Signals

    7
    0 Votes
    7 Posts
    11k Views
    N

    Thanks so much for the reply/answer :) It works!!!

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • [SOLVED]Getting string from QSql query

    5
    0 Votes
    5 Posts
    9k Views
    I

    Using QSqlQueryModel solved my problem.

    Sample code which shows my solution:

    @def clickedSlot(self,index):
    rownumber = index.row()
    colnumber = index.column()
    self.model = QSqlQueryModel(self)

    self.model.setQuery("SELECT * FROM cases") tempname = self.model.data(self.model.index(rownumber, 1)) templastname = self.model.data(self.model.index(rownumber, 2)) fullname = tempname + ' '+ templastname print(fullname) #prints the result to the console.@
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • [SOLVED]PyQT and QTableView

    5
    0 Votes
    5 Posts
    9k Views
    I

    Thank you for your observation and general promptness to answer my question. In the future, I will translate my code to English for forums ;) In general, I find my native language (Serbian) more descriptive, and it helps me distinguish "code" from "object names".

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    4 Posts
    5k Views
    A

    Great, thanks for reporting back with your solution!

  • 0 Votes
    2 Posts
    2k Views
    N

    Solved it :)

    Code for anyone who needs it in the future:

    @parent.setAttribute(QtCore.Qt.WA_DeleteOnClose)@

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    3 Posts
    3k Views
    J

    Well. I'm sorry, but this problem isn't related to bindings - small portions of code should be understandable for C++ Qt programmer. I thought this issue would suit better to General & Desktop...

    Please help.