Skip to content

Language Bindings

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

    Thank you guys for your answers. I use Windows 7 with Python 2.7.6 and Pyside as Qt-Python bindings. But i also like to test it on a Debian or openSUSE Linux. I read in the API guide to use QFileSystemModel instead of deprecated QDirModel. If i use

    @self.dirModel = QDirModel()
    self.sourceTreeView.setModel(self.dirModel)@

    in my code, the TreeView gets automatic updated when i insert/remove my USB-Stick. I thought i can have that behavior also with QFileSystemModel() in some configuration.

    So what is the best way to detect an insert/remove of an USB-Stick on Windows and Linux using Pyside Qt bindings?

  • [PyQt] Custom Scrollbar design {SOLVED}

    5
    0 Votes
    5 Posts
    17k Views
    jazzycamelJ

    Try the following:

    @
    import sip
    sip.setapi('QVariant',2)
    sip.setapi('QString',2)

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

    class ScrollBar(QScrollBar):
    def init(self, parent=None, **kwargs):
    QScrollBar.init(self, parent, **kwargs)

    self.setStyleSheet(""" QScrollBar:horizontal { border: none; background: none; height: 26px; margin: 0px 26px 0 26px; } QScrollBar::handle:horizontal { background: lightgray; min-width: 26px; } QScrollBar::add-line:horizontal { background: none; width: 26px; subcontrol-position: right; subcontrol-origin: margin; } QScrollBar::sub-line:horizontal { background: none; width: 26px; subcontrol-position: top left; subcontrol-origin: margin; position: absolute; } QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal { width: 26px; height: 26px; background: none; image: url('./glass.png'); } QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { background: none; } /* VERTICAL */ QScrollBar:vertical { border: none; background: none; width: 26px; margin: 26px 0 26px 0; } QScrollBar::handle:vertical { background: lightgray; min-height: 26px; } QScrollBar::add-line:vertical { background: none; height: 26px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { background: none; height: 26px; subcontrol-position: top left; subcontrol-origin: margin; position: absolute; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { width: 26px; height: 26px; background: none; image: url('./glass.png'); } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; } """)

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

    self.setWindowTitle("Custom Scroll Bar Example") l=QVBoxLayout(self) self._scrollArea=QScrollArea(self) self._scrollArea.setVerticalScrollBar(ScrollBar(self)) self._scrollArea.setHorizontalScrollBar(ScrollBar(self)) w=QWidget(self) ll=QGridLayout(w) for i in xrange(20): for j in xrange(10): ll.addWidget( QPushButton( "Button ({0},{1})".format(i,j), self ), i, j ) self._scrollArea.setWidget(w) l.addWidget(self._scrollArea) self.resize(250,400)

    if name=="main":
    from sys import argv, exit

    a=QApplication(argv) w=Widget() w.show() w.raise_() exit(a.exec_())

    @

    It should look something like:

    !http://s24.postimg.org/rhcr4uzs5/Screen_Shot_2014_05_06_at_12_21_29.png(Custom Scroll Bar Example Screenshot)!

    You'll just have to find an image to substitute for my 'glass.png'.

    Hope this helps ;o)

  • 0 Votes
    6 Posts
    2k Views
    EddyE

    My pleasure!

    Happy coding

  • 0 Votes
    3 Posts
    1k Views
    SGaistS

    Hi,

    To add to JKSH, the same principles applies to Python. This way you keep your code clean by having your MainWindow related code inside the class. So It's not your application main function that is responsible for the MainWindow setup. It will also make your code easily maintainable.

  • 0 Votes
    2 Posts
    963 Views
    P

    I cracked it myself anyway.

    I am not sure what exactly happend, I deleted the system generated file when debug (file name : Qt_PATH_System_Debug) and re compiled in debug mode it works all fine

  • 0 Votes
    3 Posts
    5k Views
    SGaistS

    Hi,

    To add to JvdGlind, toAscii and its fellow conversion function returns a temporary QByteArray so calling

    @char *foo = myQString.toAscii().data();
    doSomethingWithFoo(foo);@

    Will lead to undefined behavior.

    The correct way would be
    @
    QByteArray myAsciiByteArray = myQString.toAscii();
    char *foo = myAsciiByteArray.data();
    doSomethingWithFoo(foo);@

  • 0 Votes
    3 Posts
    7k Views
    D

    Can you show me an example of how to do this? I can't understand this link.

    thanks!

  • 0 Votes
    4 Posts
    2k Views
    SGaistS

    You should anyway try to create a minimal application. That way you can determine if it's a Qt bug or a PySide thing.

    Also, another thing to try is a more recent version of Qt like 4.8.6 is around the corner.

  • 0 Votes
    2 Posts
    1k Views
    T

    Issue resolved. I posted a "patch":":http://lists.qt-project.org/pipermail/pyside/2014-April/002013.html on the pyside mailing list.

  • Direct stdio to combo box

    4
    0 Votes
    4 Posts
    1k Views
    jazzycamelJ

    Glad it worked. Can you mark the thread as [solved] if thats the case ;o)

  • 0 Votes
    2 Posts
    2k Views
    EddyE

    Please dont make duplicate posts. I will close this one

  • 0 Votes
    9 Posts
    7k Views
    A

    Another question regarding the indentation : )
    I have one child that has a QWidgets set for all the columns in a row (each row has it's own QWIdget)... It has some gradient in the background. And then the indentation is just a solid color depending on what row it gets to.. Is there a way that I can set QWidget to cover that indentation? (I tryed simpliest: QWidget.move(-30, 0) but that didn't work :) ) Do I have to make a Delegate or can I avoid that?

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    6 Posts
    2k Views
    Y

    Oh, sorry, the wrong email AD ;(

    Email yurenjimi@gmail.com

    [quote author="wwolff" date="1390431009"]I try send it , but your e-mail is invalid.[/quote]

  • Hide and show group at runtime

    4
    0 Votes
    4 Posts
    1k Views
    SGaistS

    Then you should make a separate widget for each group, it will simplify the handling.

    For the undo part, have a look at QUndoStack

    For the layout part, it seems you will do it vertically, so you can use a QVBoxLayout

    Hope it helps

  • 0 Votes
    6 Posts
    3k Views
    SGaistS

    removeRow to remove a row of text.

    And to save take the other way of loading, go trough each row of your model and write its content to a QFile

  • QComboBox User select Signal

    2
    0 Votes
    2 Posts
    1k Views
    C

    Create a QComboBox derived class and reimplement "mousePressEvent":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#mousePressEvent

  • 0 Votes
    4 Posts
    2k Views
    S

    Thank you very much for these they look like they will do the job nicely.

  • Pyside Dynamic Object Management of QML

    1
    0 Votes
    1 Posts
    834 Views
    No one has replied
  • Pyside createObject() Bug

    1
    0 Votes
    1 Posts
    884 Views
    No one has replied