qt5

Add objects to QML layout from C++

一世执手 提交于 2019-12-13 19:36:13
问题 How can I, from the C++, add some more Rectangle s dynamically to the one with id root ? For example, two more Rectangle s colored red and green ? main.qml: Rectangle { id: root } Typical QML objects to add under 'root': Rectangle { color: "red"; width: 200; height: 200 } Rectangle { color: "green"; width: 200; height: 200 } Qt Creator generated main.cpp : int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral

QDockWidget starting size

时光怂恿深爱的人放手 提交于 2019-12-13 19:04:30
问题 I'm somewhat stuck on what feels like it should be a simple problem. I've got QMainWindow with several QDockWidgets. The QDockWidget (_tree_dock in my code) starts in the LeftDockWidgetArea. It contains a QWidget (dockWidgetContents_2) which contains a QTreeWidget (_tree_view). I can resize/move around the QDockWidget at runtime without any problems, however, when the program starts up the QDockWidget is slightly too small. I'm able to shrink the QDockWidget quite a bit so I know it isn't at

QTreeView custom row height of individual rows

强颜欢笑 提交于 2019-12-13 18:18:42
问题 Is it possible to redefine the row height of certain individual rows within a QTreeView ? I have a custom QTreeView , custom QAbstractItemModel and a custom QStyledItemDelegate , but it seems that all the sizeHint methods are either called only once (initially) or are not virtual in the base classes. Qt Version 4.7.4, no upgrade to 5 possible. Any help appreciated. 回答1: Reimplement the delegate’s sizeHint(). Found an example in some production code of mine. It is shown simplified below. In

Going from Qt4 to Qt5 on Linux: This application failed to start because it could not find or load the Qt platform plugin “xcb”

偶尔善良 提交于 2019-12-13 18:17:41
问题 I'm moving from Qt4 (4.8.6) to Qt5 (5.4.1) in cross-build environment (GAR environment, MiniMyth2 project). I have perfectly building and running Qt4. I already successful cross-compiled and install Qt5. For reference - here is configure output: Configure summary Building on: linux-g++-64-garbuild (x86_64, CPU features: mmx sse sse2) Building for: linux-g++-64-garhost (x86_64, CPU features: mmx sse sse2) qmake vars .......... styles += mac fusion windows DEFINES += QT_NO_MTDEV CONFIG += use

How do I use QStyle::SH_ToolTip_WakeUpDelay to set tooltip wake-up time?

南楼画角 提交于 2019-12-13 18:09:36
问题 It seems QStyle::SH_ToolTip_WakeUpDelay can be used to set tooltip wake-up time. How do I do it in C++ code? 回答1: You can use a QProxyStyle to override the default hints provided by whatever style you're using. Like: class ProxyStyle : public QProxyStyle { Q_OBJECT public: int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE { if (hint == QStyle::SH_ToolTip_WakeUpDelay) return 123; // or whatever you want return

Overlay while loading page into QWebView

China☆狼群 提交于 2019-12-13 17:11:14
问题 Let's say we have a barebones QWebView: #include <QApplication> #include <QWebView> int main(int argc, char** argv) { QApplication app(argc, argv); QWebView view; view.show(); view.setUrl(QUrl("http://google.com")); return app.exec(); } How can I display a graphic overlay, preferably fullscreen with transparency and minimal animation (like timer/beachball/etc.) from when the page starts loading till it's finished? Should also be triggered when url changes from within the QWebView. 回答1: You

My Qt5 executable does not run outside of Visual Studio 2010

一个人想着一个人 提交于 2019-12-13 14:25:21
问题 I have done a big project with Qt5 and visual Studio 2010. Everything is well inside of visual studio using the run button. But my goal is of course to release it to other persons, without visual studio. My problem is: I can't get the .exe run outside of visual studio. I was asked for several dll's at first, I found them all in the Qt5 bin folder. But know I got rid of those messages, when I wan't to open my exe, nothing happens. Just nothing..... I cannot even find my exe in the windows task

Need help doing simple rendering with Qt5 Qml + OpenGL

旧城冷巷雨未停 提交于 2019-12-13 14:18:42
问题 I need to make it so part of my Qml view is “taken over” by some non-Qt OpenGL rendering, and I was having issues getting a texture to display properly so I thought I would just draw a line and get that to work before moving on to more complicated code. For those not familiar with Qt5, the entire window is drawn using OpenGL, and I'm hooking into Qt's OpenGL drawing mechanism using their QQuickWindow::beforeRendering() signal which means my painting code is executed every redraw (every

Qt table widget, button to delete row

巧了我就是萌 提交于 2019-12-13 14:03:02
问题 I have a QTableWidget and for all rows I set a setCellWidget at one column to a button. I would like to connect this button to a function that delets this row. I tried this code, which does not work, because if I simply click my button I do not set the current row to the row of the button. ui->tableWidget->insertRow(ui->tableWidget->rowCount()); QPushButton *b = new QPushButton("delete",this); ui->tableWidget->setCellWidget(ui->tableWidget->rowCount()-1,0,b); connect(d,SIGNAL(clicked(bool))

JNI_OnLoad returned bad version (-1)

笑着哭i 提交于 2019-12-13 13:26:46
问题 I'm trying to load the Qt5Core library in my Android application and I get this: JNI_OnLoad returned bad version (-1) in /data/data/com.xxx.yyy/lib/libQt5Core.so 0x41a8f3c0 Failed to load library : Qt5Core due to link error unknown failure java.lang.UnsatisfiedLinkError: unknown failure at java.lang.Runtime.loadLibrary(Runtime.java:370) This is the way how I'm trying to load it: System.loadLibrary(s); where "s" is an array containing several library names. The other libraries are loaded