qt4

Qt QHBoxLayout percentage size

本秂侑毒 提交于 2019-12-18 12:54:31
问题 How can I maintain an aspect ratio between two QHBoxLayouts? For instance I want a QHBoxLayout to be one third of the entire window width and the other to be two thirds of the entire window width: How can I achieve this? I tried messing with the size hints of the controls in them but that didn't work out 回答1: void QSizePolicy::setHorizontalStretch(uchar stretchFactor) Example: QHBoxLayout* layout = new QHBoxLayout(form); QWidget* left = new QWidget(form); QSizePolicy spLeft(QSizePolicy:

Qt/Necessitas - reasonable QFileDialog replacement/skin?

元气小坏坏 提交于 2019-12-18 12:38:09
问题 I'm looking for a nice way to address porting Qt applications to Qt/Necessitas (Android). Some of the QtGUI widgets are absolutely atrocious - unfortunately, including QFileDialog. Do you know of any replacements with a proper look and feel? Is making QFileDialog usable anywhere near high priority for Necessitas developers? #include <QApplication> #include <QFileDialog> int main(int argc, char* argv[]) { QApplication a(argc, argv); QString fileName = QFileDialog::getOpenFileName(NULL, QObject

Qt creator Adding external library (still: Cannot open include file: 'GL/glew.h')

好久不见. 提交于 2019-12-18 12:29:43
问题 I followed the instruction: In the Projects pane, open the project file (.pro). Right-click in the code editor to open the context menu and select Add Library.... Then the following lines were added into the pro file: win32:CONFIG(release, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32d INCLUDEPATH += $$PWD/D:/OpenGL/glew-1.5.4/include DEPENDPATH += $$PWD/D:/OpenGL/glew-1.5.4

Using QTDesigner with PyQT and Python 2.6

China☆狼群 提交于 2019-12-18 10:16:13
问题 I'm new to Python and am starting to teach myself GUI programming (hopefully) using PyQT4.7 and Python 2.6 I just downloaded the whole PyQT/QT4 package (including QTDesigner) from the PyQT website, however it seems QTDesigner, which looks amazing to use as a newbie (since you can see all the attributes/properties/defaults etc) of each widget and visually edit the properties is great, but PyQT seems not to set QTDesigner to integrate directly with with PyQT and PyQTs python code generation

Set Environment Variables for startDetached() QProcess

我只是一个虾纸丫 提交于 2019-12-18 09:21:25
问题 In Qt4, there is QProcess::setProcessEnvironment() for setting Env variables for the newly spawn process. However, QProcess::startDetached() is a static member function, so setProcessEnvironment() doesn't apply. How does one set Env variables for a detached process in Qt? 回答1: It is a known old bug: http://bugreports.qt-project.org/browse/QTBUG-2284. You need to overload startDetached function to support your own environment. Take a look at Qt sources to see how to do that: http://code.qt.io

Access values of dropActions in model (PySide/PyQt/Qt)

a 夏天 提交于 2019-12-18 09:08:24
问题 In a QTableModel when I enter the following: print model.supportedDropActions() I just get: <PyQt4.QtCore.DropActions object at 0x00000000081172E8> How can I access an actual list of the supported drop actions from this object? At the documentation, it says, "The DropActions type is a typedef for QFlags. It stores an OR combination of DropAction values." Note I am doing this in Python (PySide). Related posts: Drag and drop rows within QTableWidget 回答1: Background First, make sure you

Using SQLite custom functions with Qt

◇◆丶佛笑我妖孽 提交于 2019-12-18 09:05:11
问题 I'm trying to create a custom function for a SQLite database I'm using with Qt. I found information on how to create the function and it seems to work correctly on a x86 system. Instead, it seems to be failing with a segfault on an ARM device. This is the code I wrote: static bool createSQLiteFunctions(const QSqlDatabase& db) { // Get handle to the driver and check it is both valid and refers to SQLite3. QVariant v = db.driver()->handle(); if (!v.isValid() || qstrcmp(v.typeName(), "sqlite3*")

Macro expansion in moc

拟墨画扇 提交于 2019-12-18 08:24:57
问题 I'd like to store some class info using Q_CLASSINFO macro. However I would like to wrap it in my own macro, for example: #define DB_TABLE( TABLE ) \ Q_CLASSINFO( "db_table", #TABLE ) #define DB_FIELD( PROPERTY, COLUMN ) \ Q_CLASSINFO( "dbcol_" #PROPERTY, #COLUMN ) class Foo : public QObject { Q_OBJECT DB_TABLE( some_table ) DB_FIELD( clientName, client_name ) } Unfortunately, moc doesn't expand macros so the Q_CLASSINFO is not added. I've tried to feed moc with already preprocessed source,

How to allow resizing of QMessageBox in PyQt4

雨燕双飞 提交于 2019-12-18 07:04:22
问题 I'm using the nice feature in QMessageBox to optionally show detailed text to the user. However, the window after expansion is still fairly small, and one immediately tries to resize the window so more of the details are visible. Even after setting what I think are the proper settings it won't allow resizing. Here's the relevant snippet of PyQt4 code: mb = QMessageBox() mb.setText("Results written to '%s'" % filename) mb.setDetailedText(str(myData)) mb.setSizePolicy(QSizePolicy.Expanding,

Qt: How to play sound witout blocking main thread?

此生再无相见时 提交于 2019-12-18 05:12:38
问题 I'm wondering is there a simple way in Qt to play sound without blocking the main thread ? I know that normaly I should start a seperate thread to do this. But maybe there is a shortcut ? :) Thanks for help. 回答1: http://doc.qt.nokia.com/latest/qsound.html Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static play() function: QSound::play("mysounds/bells.wav"); It seems like this is an