qt

How to add a rectangle to a QML ChartView?

眉间皱痕 提交于 2021-02-16 18:22:58
问题 I want to put a number of rectangles as overlays to show regions of interest on a ChartView of ScatterSeries. However when I try to do this it is clearly using a different coordinate system to that of the ScatterSeries as it is drawn in a completely different place. For example the following is intended to draw a rectangle that captures all of the ScatterSeries but it just draws a small green rectangle top left as shown in the screenshot. ChartView { id: view Layout.fillWidth : true Layout

QML Layouts: How to give weights to items in a row or column layout?

廉价感情. 提交于 2021-02-16 16:30:10
问题 I'm trying to figure out a way to layout items proportionally by specifying a kind of weight for each item. For example the way Android does their layouts. The way I'm trying to achieve it is like so: import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 GridLayout { columns: 4 width: 640 height: 480 Rectangle { color: "red" Layout.fillHeight: true Layout.fillWidth: true Layout.columnSpan: 1 } Rectangle { color: "#80000000" Layout.fillHeight: true Layout.fillWidth: true

How to set cursor shape to '>' in a QTextEdit?

天涯浪子 提交于 2021-02-16 14:30:27
问题 I am trying to mimic a command-line client. I wish to set the cursor shape to '>', to show messages to user. I don't see that shape in the options provided by QCursor. Is there a way to set custom shapes to widget cursors? 回答1: You need to set the QTextEdit's viewport's cursor: http://doc.qt.nokia.com/stable/qtextedit.html "The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. It can be changed through the viewport()'s cursor property." e.g. To hide the cursor completely

Example SLOT/SIGNAL between two object QT

梦想的初衷 提交于 2021-02-16 14:20:38
问题 My app, consists in 2 different object (QObject and QMainWIndow), and I am wondering how to communicate between them with SLOT/SIGNAL. Moreover, does existing better approach ? Can someone make an simple example ? Thank :) sample mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "ui_mainwindow.h" #include "object.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0);

How to use std::string in a QLineEdit?

别来无恙 提交于 2021-02-16 13:31:31
问题 I have the following problem. I am trying to integrate a large code written by me with a Qt interface. Some of my functions return std::string . I did not succeed in making QLineEdit::setText accept them (other functions returning char do not give me problems). What should I do? Thanks! Giuseppe 回答1: Try this: std::string a = "aaa"; lineEdit->setText(QString::fromStdString(a)); You will need Qt with STL support. 回答2: There's no constructor for QString that takes a std::string . Convert it

How to use std::string in a QLineEdit?

我怕爱的太早我们不能终老 提交于 2021-02-16 13:29:09
问题 I have the following problem. I am trying to integrate a large code written by me with a Qt interface. Some of my functions return std::string . I did not succeed in making QLineEdit::setText accept them (other functions returning char do not give me problems). What should I do? Thanks! Giuseppe 回答1: Try this: std::string a = "aaa"; lineEdit->setText(QString::fromStdString(a)); You will need Qt with STL support. 回答2: There's no constructor for QString that takes a std::string . Convert it

KeyEvent in MainWindow (PyQt4)

[亡魂溺海] 提交于 2021-02-16 11:40:15
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

KeyEvent in MainWindow (PyQt4)

早过忘川 提交于 2021-02-16 11:36:15
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

KeyEvent in MainWindow (PyQt4)

时光总嘲笑我的痴心妄想 提交于 2021-02-16 11:35:34
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

QMYSQL driver not loaded on Windows

家住魔仙堡 提交于 2021-02-15 06:53:31
问题 I am trying to implement a database system in my Qt application. For this purpose, I am trying to use MySQL (with the related QMYSQL driver). My class connection-function is written below. Assuming that connection is defined as a private class member: private: QSqlDatabase connection; we have the following: database::database() : connection() { this->connection.addDatabase("QMYSQL"); this->connection.setHostName(p.database->server_addr); this->connection.setUserName(p.database->username);