Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
865 Topics 3.4k Posts
  • [Solved] Qt + Java (from Android)

    4
    0 Votes
    4 Posts
    4k Views
    X
    This is the source code of the project I was working on: https://github.com/xtingray/tupi.mobile Last year, I compiled it using MInistro/Qt4 and it worked. I ported the small code to Qt5 but I haven't tried again, so I have no idea if it works now. I hope this can gives you a hint. Good luck!
  • New Developer with QT how to start

    8
    0 Votes
    8 Posts
    3k Views
    R
    thanks for your info. But i see that in my system QT is installed as below path: C:\Qt\Qt5.3.1\Examples\Qt-5.3\activeqt\dotnet\walkthrough - here i could see one csharp project is there. I am trying to open that project in vs.net 2013. and i am getting the below error like "Error 10 The type or namespace name 'AxwrapperaxLib' could not be found (are you missing a using directive or an assembly reference?) C:\Qt\Qt5.3.1\Examples\Qt-5.3\activeqt\dotnet\walkthrough\Form1.cs 15 11 csharp Any comments on the above, i understood some libraries need to add my project, but i could not able to find which library and where should i get them please help out the answer..
  • Install QT Jambi on Mac OS X Mavericks

    2
    0 Votes
    2 Posts
    2k Views
    SGaistS
    Hi and welcome to devnet, I would say that @libQtCore.4.dylib: mach-o, but wrong architecture@ is the hint you are looking for.
  • PySide: QWebPage.isModified() is out of sync

    2
    0 Votes
    2 Posts
    1k Views
    B
    You may notice from the example that the forms I care to detect are not mine. Here's another couple of ways I tried to do the same thing (catching forms): 1- Attach onsubmit javascript handler on the form (this doesn't respond at all): @def _integrateForms(self, ok): this is the page's loadFinished handler if ok: page = self.browser.page() frame = page.mainFrame() frame.addToJavaScriptWindowObject("reporter", self) form = frame.findFirstElement("form") form_onsubmit = form.attribute("onsubmit") new_onsubmit = "reporter.submitPerformed(this.elements);" + form_onsubmit form.setAttribute("onsubmit", new_onsubmit) def submitPerformed(self, values): print values@ 2- Evaluate javascript on the form on the page's loadStarted event: @def loadStartedHandler(self): page = self.browser.page() frame = page.mainFrame() form = frame.findFirstElement("form") values = form.evaluateJavaScript(""" var ret = {}; var unwanted_inputs = ["submit"]; for (var i = 0; i < this.length; ++i) { elem = this.elements[i]; // do not include hidden elements neither submit buttons if ( elem.offsetParent !== null && unwanted_inputs.indexOf(elem.type) === -1 ) ret[elem.name] = elem.value; } ret; """) print "Values: {}".format(values)@ This last one seems to work, with some extra outputs.
  • Pyside and QWS on embedded arm platform

    14
    0 Votes
    14 Posts
    7k Views
    SGaistS
    For that one I can't, AFAIK, it's auto generated code
  • PySide Installer on Windows

    2
    0 Votes
    2 Posts
    1k Views
    C
    Doesn't actually work with pip and easy_install as suggested "here":http://qt-project.org/wiki/PySide_Binaries_Windows And I am still using the old installer for windows. Hope this will be fixed.
  • Question about using UI/xml files from Qt designer in Pyside

    2
    0 Votes
    2 Posts
    3k Views
    B
    I think I solved this. I was calling loadUi in the function call. That was not needed because the call to loadUi was already defined in the runoptions class. Silly me. I am still getting this error; bq. Object::connect: No such slot runoptions::accept() Object::connect: (sender name: ‘buttonBox’) Object::connect: (receiver name: ‘Dialog’) Object::connect: No such slot runoptions::reject() Object::connect: (sender name: ‘buttonBox’) Object::connect: (receiver name: ‘Dialog’) The 'runoptions' form contains an OK and Cancel button which do not work. Not sure how to fix that but at least I am making some progress. I am not getting the "Designer" error anymore. Cheers,
  • PySide, pySerial and threading causes segfault

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • Accessing objects into another class

    6
    0 Votes
    6 Posts
    2k Views
    SGaistS
    Just setup your database and open it once e.g. in your main function. There's no need to close/open it every time you want to access it unless you have a very good reason
  • Integrating Qt as debug tool for server app

    4
    0 Votes
    4 Posts
    1k Views
    A
    moderator hat on: Using foul language is not acceptable here. Please practice patience for getting replies on your queries. If you need immediate answers, get paid support from one of the many vendors offering that. On your actual query: I think you're having a problem integrating event loops. I would not recommend trying to integrate a Qt UI into a service. Instead, I'd set up the design in a way that your service can communicate with an application via a simple protocol, and you keep the GUI as a separate process from the actual service. A local socket will do, but a network port just as well. DBUS may be good option for you as well.
  • [PySide] List model from PySide to QML

    2
    0 Votes
    2 Posts
    2k Views
    K
    Still seeking a reply to this.
  • Exit QThread Cleanly

    2
    0 Votes
    2 Posts
    2k Views
    jazzycamelJ
    Before I answer your question I will first say that, despite examples given in the docs, it is generally considered a bad idea to subclass QThread and instead create a worker object that is moved into a thread. To stop a QThread you need to call quit() and, if that fails, terminate(). The issue here is that you're running a blocking method and no event loop so these methods will not work on there own. What you therefore need is a flag that is checked on every iteration of the forever loop and set by a signal/slot call from your main thread when the GUI exits. The following files form a minimal working example: widget.h @ #ifndef WIDGET_H #define WIDGET_H #include <QWidget> class QThread; class Widget : public QWidget { Q_OBJECT public: explicit Widget(QWidget *parent = 0); ~Widget(); private: QThread *thread; signals: void stopThread(); public slots: void start(); void tick(); }; #endif // WIDGET_H @ widget.cpp @ #include "widget.h" #include "threaded.h" #include <QVBoxLayout> #include <QPushButton> #include <QThread> #include <QDebug> Widget::Widget(QWidget *parent) : QWidget(parent) { QVBoxLayout *l=new QVBoxLayout(this); QPushButton *startButton=new QPushButton("Start", this); connect(startButton, SIGNAL(clicked()), this, SLOT(start())); l->addWidget(startButton); } Widget::~Widget() { if(thread->isRunning()){ emit stopThread(); thread->quit(); if(!thread->wait(5000)){ thread->terminate(); if(!thread->wait(5000)) qDebug() << "Failed to terminate!"; } } } void Widget::start(){ thread=new QThread(); Threaded *threaded=new Threaded(); connect(this, SIGNAL(stopThread()), threaded, SLOT(stop())); connect(threaded, SIGNAL(tick()), this, SLOT(tick())); connect(thread, SIGNAL(started()), threaded, SLOT(work())); threaded->moveToThread(thread); thread->start(); } void Widget::tick(){ qDebug() << "tick"; } @ threaded.h @ #ifndef THREADED_H #define THREADED_H #include <QObject> class Threaded : public QObject { Q_OBJECT public: explicit Threaded(QObject *parent = 0); private: bool mStop; signals: void tick(); public slots: void work(); void stop(); }; #endif // THREADED_H @ threaded.cpp @ #include "threaded.h" #include <QMutex> #include <QWaitCondition> #include <QCoreApplication> Threaded::Threaded(QObject *parent) : QObject(parent), mStop(false) {} void Threaded::work(){ QMutex dummy; QWaitCondition waitCondition; forever{ dummy.lock(); waitCondition.wait(&dummy, 1000); emit tick(); dummy.unlock(); QCoreApplication::processEvents(); if(mStop) break; } } void Threaded::stop(){ mStop=true; } @ main.cpp @ #include <QtGui/QApplication> #include "widget.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec&#40;&#41;; } @ Hope this helps ;o)
  • [PySide] Use QProcess or QThread in this case ?

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • [SOLVED] PyQt - Define a widget visible area in a QGridLayout

    7
    0 Votes
    7 Posts
    6k Views
    J
    Thank you so much! I love your last example too! With that teh post it's complete, thanks for eveything :)
  • Segfault after signal emit

    4
    0 Votes
    4 Posts
    3k Views
    A
    It would be good if someone more knowledgeable than me could comment on my first attempt that ends in a segfault. is this a bug in pyside or is it not intended to be used like that?
  • 0 Votes
    4 Posts
    5k 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
    19k 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
  • Inherited Qt classes programming doubt (newbie)

    3
    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
    1k 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