Posts

Showing posts with the label qt

QT Creator copies SQLite as empty database

Image
Clash Royale CLAN TAG #URR8PPP QT Creator copies SQLite as empty database I have a sqlite file in the folder of my QT creator app. I even did Projects (right click) -> add existing files, and added it to my project. The file gets copied to the build directory. However, it contains no tables or data. I need the data in my database file to persist during the copy. Is there any way to ensure this? do you mean you want to keep the data but change the schema? – Amfasis 2 hours ago 1 Answer 1 What happens is that the database is not being copied, since attaching it to the .pro does not imply that it will be moved to the build folder. And then why is there .db in the build folder? sqlite if it does not find the .db it will create it, so you get the empty fil...

Qt async call: how to run something after an async call has finished its job

Image
Clash Royale CLAN TAG #URR8PPP Qt async call: how to run something after an async call has finished its job I have code like below which does an async call: QMetaObject::invokeMethod(this, "endSelectionHandling", Qt::QueuedConnection); I want to modify the code like this: QMetaObject::invokeMethod(this, "endSelectionHandling", Qt::QueuedConnection); // I want to add statements here which depend on the result of the above async call. // How can I wait for the above async call to finish its jobs? How can I wait for Qt asycn call to finish its job? Is there a better approach? If you want to wait right after the function call then why don't you call it directly i.e. blocking call? That would be the perfect solution in your case unless there's something in between that you want to do. – Azeem yesterday ...

what is the difference if we run qt inside docker and outside docker( without using docker)?

Image
Clash Royale CLAN TAG #URR8PPP what is the difference if we run qt inside docker and outside docker( without using docker)? I would like to know what is the difference if we run OpenGl programs using qt creator which is running inside and outside docker. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to have text centered inside each slice of a pie chart?

Image
Clash Royale CLAN TAG #URR8PPP How to have text centered inside each slice of a pie chart? I would like to get the text labels (percentages) centered within each pie slice. It currently works a bit for two of the quadrants: What am I doing wrong? void PieChartWidget::paintEvent(QPaintEvent *) { QPainter painter(this); QRectF size; painter.setPen(QPen(Qt::black, 2)); if (this->height() > this->width()) { size = QRectF(5, 5, this->width() - 10, this->width() - 10); } else { size = QRectF(5, 5, this->height() - 5, this->height() - 10); } double sum = 0.0, startAng = 0.0; double angle, endAng; double percent; for (int i = 0; i < qvValues.size(); i++) { sum += qvValues[i]; } for (int i = 0; i < qvValues.size(); i++) { percent = qvValues[i] / sum; angle = percent * 360.0; endAng = startAng + angle; painter.setBrush(qvColors[i]); painter.drawPie(size, static_cast<int>(startAng ...

matplotlib crosshair cursor in PyQt dialog does not show up

Image
Clash Royale CLAN TAG #URR8PPP matplotlib crosshair cursor in PyQt dialog does not show up I want to have a crosshair at the cursor in my matplotlib window. This works out in the example, given in the matplotlib gallery. But unfortunately, it does not work if I have the matplotlib widget in a Qt dialog window ( QDialog ). matplotlib QDialog This is my sample of code, where I want to instantiate the matplotlib.widgets.Cursor object, but nothing shows up. matplotlib.widgets.Cursor import sys from PyQt4 import QtGui from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas import matplotlib.pyplot as plt from matplotlib.widgets import Cursor class Window(QtGui.QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) self.figure = plt.figure(facecolor='white') self.canvas = FigureCanvas(self.figure) layout = QtGui.QVBoxLayout() layout.addWidget(self.canvas) self.setLayout(layout) ...

Problems with MySql Database calls in C++ Classes

Image
Clash Royale CLAN TAG #URR8PPP Problems with MySql Database calls in C++ Classes I'm currently developing a desktop app that acesses a remote MySql database with Qt/C++. My approach was to create multiple .h/.cpp files (corresponding to different ui widgets) and call a general .h/.cpp database manager file that handles login, querys, etc. Unfortunately I am kinda stuck because either I get the "QSqlDatabasePrivate::removeDatabase: connection ' databaseName ' is still in use, all queries will cease to work." or another kind of odd mistake like 'query.exec: database is not open'. I've been searching for a day and I can't find anything that helps my case so I decided to try my luck here :) i'll leave you the database manager and login .h/.cpp files atm: db.h #ifndef DB_H #define DB_H #include <QtSql> #include <QSqlDatabase> #include <QtDebug> #include <QMessageBox> class db { private: friend class login; QSqlDataba...

QCPItemLine is being paint automatically

Image
Clash Royale CLAN TAG #URR8PPP QCPItemLine is being paint automatically Im trying using QCustomPlot in my gui MainWindow.h public: void initArrow(); private: QCustomPlot* grid; QCPItemLine* arrow; MainWindow.cpp void MainWindow::initArrow() { arrow = new QCPItemLine(ui->grid); QPen pen(Qt::red); pen.setWidth(4); arrow->setPen(pen); arrow->setHead(QCPLLineEnding::esLineArrow); arrow->setHead(QCPLLineEnding::esDisc); } in this situation i'm playing the program, i resize the window and i see an arrow on the plot with coordinates (0,0) and (1,1). this is the code . I didnt use replot! I didnt use start! I didnt use end! in addition, when i will understand what is the problem I'm asking what is the correct way to draw a line when i'm trying to draw above other graph. normally if I'm using points it will be like: QVector<double> x; QVector<double> y; ui->grid->graph(number)->setData(x,y); ui->grid->graph(number)->replot(); but I cant ...

In Qt, how to efficiently determine that a point is inside of one of rectangles?

Image
Clash Royale CLAN TAG #URR8PPP In Qt, how to efficiently determine that a point is inside of one of rectangles? There is a large set of rectangles. Given a point, I need to quickly find if this point belongs to at least one of the rectangles, and find one. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

PyQt5. How to get cursor position in QTextEdit connected with ContextMenu?

Image
Clash Royale CLAN TAG #URR8PPP PyQt5. How to get cursor position in QTextEdit connected with ContextMenu? I try to get cursor position in QTextEdit : QTextEdit class CustomEdit(QTextEdit): self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.cursor = self.textCursor() self.menu = None self.customContextMenuRequested.connect(self.create_menu) def create_menu(self, pos): self.menu = QMenu() self.menu.addSeparator() func = self.menu.addAction(u'function') action = self.menu.exec_(self.viewport().mapToGlobal(pos)) if action == func: self.func() def func(self) print(self.cursor.positionInBlock()) but it doesn't work. What does it mean that it does not work? – eyllanesc 21 mins ago It returns wrong number that not...

How to use the Qt Designer individually and Ooffline doc for PyQt5 in Eric6?

Image
Clash Royale CLAN TAG #URR8PPP How to use the Qt Designer individually and Ooffline doc for PyQt5 in Eric6? pip install pyqt5 and then install eric6. pip install pyqt5 Now, when i open *.ui , tip could not found designer.I know I can install the entire Qt Creator to get support, but can I install only the Designer? *.ui Another question is how to open an offline PYQT5 help document in ERIC6? install pypi.org/project/pyqt5-tools – eyllanesc 8 mins ago This library has been abandoned. @eyllanesc – Martin Zhu 7 mins ago Where does it say that it has been abandoned ?, besides you want only the executable of Qt designer – eyllanesc 6 mi...

ScreenRayCaster in QML

Image
Clash Royale CLAN TAG #URR8PPP ScreenRayCaster in QML I would like to reproduce this example https://www.kdab.com/new-in-qt-3d-5-11-generalized-ray-casting/ But when I add this line in my qml file import Qt3D.Render 2.0 ... ScreenRayCaster { id: screenRayCaster } I've got this error : ScreenRayCaster is not a type My Qt version is 5.11 for vc2017 64bits. Anyone knows how to use ScreenRayCaster in QML ? try import Qt3D.Render 2.11 instead. Also don't forget to add to your *.pro file the following: QT += 3dcore 3drender 3dinput 3dquick 3dlogic qml quick 3dquickextras , one of them, what you need – folibis 19 hours ago import Qt3D.Render 2.11 QT += 3dcore 3drender 3dinput 3dquick 3dlogic qml quick 3dquickextras The doc says import Qt3D.Render 2.0 so p...

Getting 32 bit Qt framework on a PowerPC Mac

Image
Clash Royale CLAN TAG #URR8PPP Getting 32 bit Qt framework on a PowerPC Mac I installed Qt 4.8.6 on a PowerPC Mac (32 bit). However, when I do file /Library/Frameworks/.../QtTest , I get Mach-O 64-bit ... x86_64 . file /Library/Frameworks/.../QtTest Mach-O 64-bit ... x86_64 Where do I get 32 bit Qt binaries? There is no choice for this in the installer, and it seems silly that an installer run on a 32 bit machine would install 64 bit libraries. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Is it possible to play loading animation indicator while processing event in QT GUI application?

Is it possible to play loading animation indicator while processing event in QT GUI application? Below is my code, I have resolved to my Question .Al last i got solution with help of stack overflow team .It is possible to play animation (.gif file) on main thread if you are doing long task in worker thread.And other things is as with official doc QPixmap is does not supporting in worker thread .So i hope guys it will be help for Qt developer. int worker::do_Work() { int i =0; while (i<1000000) { qDebug()<<":count *i=========>"<<i; i++; } qDebug()<<"Worker process finished in Thread "<<thread()->currentThreadId(); emit finished(); } int mywidget::popup() { ui->label_2->setStyleSheet("background-color:rgb(85,255,127);border-radius:10px"); ui->label_2->setWindowFlags(Qt::FramelessWindowHint); ui->label_2->setText("Please Wait.."); ui->la...