FAQ Database Discussion Community


How to align GUI elements like this? Qt, C++

c++,qt
I need to align elements on GUI: actually, a single label, but at the specific position. I know how to use QGridLayout, QHBoxLayout, I know how to change the font to have the specified size. However, I don't know how to align the label like on this picture below. Any...

QDateTime Conversion

qt,qdatetime
I need to convert the String variable to QDateTime format my code looks QString date ="Thu Jun 18 2015"; QDateTime tmp = QDateTime::fromString(date,"ddd MMM dd yyyy HH:mm:ss"); But the result is Thu Jan 1 00:00:00 1970. Later I have to convert this date in to foramt yyyy-MM-dd HH:mm:ss, so as...

What is the difference between MinGW SEH and MinGW SJLJ?

c++,c,qt,mingw
I am just starting to learn C and installing now QT x64 (form here: http://tver-soft.org/qt64). I have two options to install: MinGW 4.9.2 SEH or MinGW 4.9.2 SJLJ. Question: Which is better to install and why? I read What is difference between sjlj vs dwarf vs seh? and https://wiki.qt.io/MinGW-64-bit#Exception_handling:_SJLJ.2C_DWARF.2C_and_SEH but...

QT-FTP Upload Error

c++,qt,ftp,qnetworkreply
I'm trying to upload a simple txt file to ftp server but getting "QNetworkReply::ContentOperationNotPermittedError" reply from the server and i think it is about my file hierarchy. Here is the file order of my ftp server and my qt-ftp configuration : QUrl url("f13-preview.125mb.com/www/home/repo/test.txt"); url.setHost("f13-preview.125mb.com"); url.setUserName("1896230"); url.setPassword("mypassword"); url.setPath("f13-preview.125mb.com/www/home/repo/"); url.setScheme("ftp"); ...

Update bindings to var properties in QML

qt,qml
If you take a look at this page it notes that bindings to var properties are not automatically updated when the object changes: Item { property var car: new Object({wheels: 4}) Text { text: "The car has " + car.wheels + " wheels"; } Component.onCompleted: { car.wheels = 6; }...

How to rename qrc file?

visual-studio,qt
There is project based on MDI example. I work with it in Visual Studio 2013. I want to rename mdi.qrc file. But after renaming I get error 1>main.obj : error LNK2019: unresolved external symbol "int __cdecl qInitResources_mdi(void)" (?qInitResources_mdi@@YAHXZ) referenced in function _main What do I need to do?...

Find last entry in a map

c++,qt,dictionary
I have a QMap<qreal,int> myMap; I need to find the largest key. Is this the only way ? I was hoping for something built in maybe. Is this good enough ? Isn't creating an iterator for a simple operation too much ? qreal maxkey() { QMap<qreal,int>::iterator it = myMap.end() -...

QFrame with background image and otherwise transparent background

c++,qt,background-image,qframe
I am making a desktop carousel app. There I need to show image widgets, which might contain other sub-widgets as well. For that I am using a QFrame with the required image as background. Here is the image I am trying to use: image link. What I want is that...

Confusion with std::pairs initialization

c++,qt,hash,unordered-map,std-pair
The code below, when compiled produces the following errors: error C2439: 'std::pair::first' : member could not be initialized error C2440: 'initializing' : cannot convert from 'int' to 'const AnalyticsToolKit::ParcelPassingLogic::ParticipantNode &' When I comment out the bottom line however, there is no such error, so there must be something wrong with...

How to pass QString variable to QFile?

qt,qstring,qfile
getData gets the chosen file from a QTreeView and displays it on label 'test', enables the 'Apply' button, which when clicked calls setTheme void OptionsDialog::getData(const QModelIndex &index) { QString selected = model2->filePath(index); ui->test->setText(selected); ui->pushButton_apply_theme->setEnabled(true); } void OptionsDialog::setTheme() { //char *file = selected->toLatin1().data(); //const std::string file = selected->toStdString(); QFile qss(selected); qss.open(QFile::ReadOnly);...

How to avoid user to click outside popup Dialog window using Qt and Python?

qt,user-interface,python-3.x,dialog,qt-creator
I created a Dialog window using Qt Creator and Python. I would like that Window stays on the top of my Gui AND avoid users to click outside that Dialog Until this dialog was closed.

passing a current time variable

c++,qt,qtimer
I am trying to get a text edit box to display the current time every 5 seconds using QTimer. I am having the current time figured in a separate method and then having the QTimer call that method and display the current time. I can not for the life of...

Unable to connect to mariadb database server with qt 4.8.5 and Ubuntu 12.04

mysql,qt,ubuntu,mariadb
I use the following code to connect to a MySQL server database. QSqlDatabase db_Server = QSqlDatabase::database("Test"); //find mysql driver db_Server = QSqlDatabase::addDatabase("QMYSQL","Test"); db_Server.setHostName("188.**.***.***"); db_Server.setPort(3306); db_Server.setDatabaseName("Test"); db_Server.setUserName("Test"); db_Server.setPassword("*********"); bool ret = db_Server.open(); if(ret) qDebug() << "Database open" else qDebug() << db_Server.lastError().text(); Lately they changed the server to mariadb and I assumed...

Running python code exported from qt creator and converted to python using pyqt5

qt,python-3.x,qt-creator,pyqt5
I recently encountered this error after attempting to run my python script. In short, I simply don't understand how I've fed three arguments. I've included what I considered to be the most relevant snippets of code. Help is very appreciated. Thank you. Traceback (most recent call last): File "DESeq_rpkm_gui.py", line...

Cmake and Qt5 linking error

c++,qt,cmake,qt5
I'm trying to build a Qt5 project with Cmake in order to add some new librairies. The cmake goes well but I have a linking issue when building : Linking CXX executable bin/qGo CMakeFiles/qGo.dir/src/main.cpp.o: dans la fonction « main »: main.cpp:(.text+0x102b): undefined reference to « qInitResources_application() » collect2: error: ld...

Qt OpenGL transform feedback buffer functions missing

c++,qt,opengl,transform-feedback
I've been following a tutorial series for learning OpenGL, and the current tutorial I'm trying to do involves creating particle systems using the OpenGL transform feedback buffer. In my application I've been using Qt version 5.4.2 for simple 2D interface design, as well as for 3D rendering since it seems...

Cannot connect (null)::selectionChanged to QTableView

c++,qt,qt-creator,signals-slots,qtableview
I have the following promoted QTableView: class QRightClickableTableView : public QTableView { Q_OBJECT public: explicit QRightClickableTableView(QWidget *parent = 0): QTableView(parent) {} private slots: void mouseReleaseEvent(QMouseEvent *e) { if(e->button()==Qt::RightButton) emit rightClicked(); else if (e->button()==Qt::LeftButton) emit leftClicked(); } signals: void rightClicked(); void leftClicked(); }; When binding the selectionChanged signal of QRightClickableTableView, but...

Compiling a Qt Application using Dev C++ on Windows

c++,qt,dev-c++
I wrote a small Qt application in Dev-C++ as shown: #include <QApplication> #include <QLabel> int main(int argc,char *argv[]) { QApplication app(argc,argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); return app.exec(); } I am quite sure I've done everything necessary to start creating Qt applications such as install Qt5.3.2, setup the...

DPI-independent constant size in QML

qt,qml,qt5,qtquick2,qt-quick
I have a visual component in my app written in QML, Qt5. I want it to always have the width of 5 cm on the screen, no matter what device is used. If I set width: somevalue, then the DPI might differ among the devices which will result in different...

QTimer::singleShot equivalent for QML

qt,qml
Consider this C++ statement (example from docs): QTimer::singleShot(600000, &app, SLOT(quit())); How to do the same in .qml JavaScript, something like this QML: Rectangle { property int counter: 0 onCounterChanged: { if (counter > 42) { // do equivalent of above C++ statement here } } // more code, which actually...

QtWidget Disable Margin for overlay widget

c++,qt,c++14,qwidget
My situation: I have a grid layout with n*n widgets inside. Additionally I place an overlay widget in the grid with position 0,0 and span n,n. Evertyhing fine with this, but there is a weird margin and I don't know what causes it... Has anyone an idea how i can...

Change attribute value of an XML tag in Qt

c++,xml,qt
I'm trying to change the language attribute of a .ts file in Qt using Qt itself. Here is the sample XML format. <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE TS> <TS language="es_ES" version="2.1"> ... </TS> I have tried different ways, but no luck. Here are the methods I used. FileIOError FileIO::changeLanguageOfTsFile( QString tsFileName,...

Attempting to read stdout from spawned QProcess

qt,signals-slots,qprocess
I've written a Qt application to create a UI to a backend Linux console application. Now, I want the console output and the standard error to be displayed in a window in my application. I've tried the following code : int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow...

SOLVED: QT: Escape slash / in saving location on a mac

osx,qt,escaping
I have HTML input I am supposed to extract 2 Strings of, build a document title string of type <string 1> / <string 2, create a PDF from the source on the users mac desktop and name it as described. I do know that a slash in a document name...

Context switches between functions and slots in a single thread?

multithreading,qt,qt5
I am implementing a small project where I am extensively using QThreads and signals/slots (and basically Qt 5). I can say I have a fair idea about how signals/slots work along with QThreads. (I have gone through all important material on StackExchange as well as these links "You are doing...

Is it possible to deploy a Qt Quick application without Qt Network on OS X?

qt,qt5,qt-quick,qtnetwork
I have a Qt Quick application using the following modules QT = core gui qml quick widgets \ core-private gui-private \ multimedia printsupport` which I deploy on OS X. Now my main binary as well as a lot of Qt Qtick plugins show a dependency on Qt Network. otool -L...

How to call a non-class member function with pointers as parameters with QtConcurrent::run?

c++,qt,pointers,qtconcurrent
I want to call a recursive non-class member function used to erase a given folder with all of its files using Qt 4.8 for Embedded Linux: bool removeFiles(const QString & dirName, Interface::ProgressDialog* const poProgressDialog, qint32* const itemDeletedCounter) { bool result = true; try { QDir dir(dirName); if (dir.exists(dirName)) { Q_FOREACH...

QSerialPort new signal slot syntax no matching member function for call to 'connect'

c++,qt,qt5,qtserialport
I am trying to use the new signal and slot syntax, but I am getting a compile error at connect function. How to use the new syntax in this case? // Qt 5.4.1, Apple LLVM version 6.1.0 and qmake 3.0 private slots: void onError(QSerialPort::SerialPortError code); private: QSerialPort *m_port; Link::Link(QObject *parent)...

How to change the opacity of Qt MainWindow?

qt,qmainwindow
How to change the opacity of the Qt MainWindow by some values? My main window contains nothing but just somehow I need to change the opacity using keystrokes. It looks like this now. I tried to set using this->setWindowOpacity(0.5); didn't get anything opacity effect. ...

Trying to load 2d texture with glTexImage2D, but just getting blank

c++,qt,opengl
I am trying to create a 2d texture to display on my Qt/OpenGL application. I then created a Quad that fills up screen to place it, but I all I ever get is a white screen without any errors. Does anyone see anything wrong with my code? #include "AppGLWidget.h" #include...

Can't create QList with custom class

c++,qt,qlist
I'm trying to create QList of custom class objects, but I got error: error: C2923: 'QList' : 'Read' is not a valid template type argument for parameter 'T' My code (User header): #ifndef USER_H #define USER_H #include <QString> #include <QList> #include "read.h" class User { protected: int id; QString username;...

What does QHeaderView::paintSection do such that all I do to the painter before or after is ignored

c++,qt,qpainter,qheaderview
This question is further development of this post and is different, though may seem similar as this one. I am trying to reimplement QHeaderView::paintSection, so that the background returned from the model would be honored. I tried to do this void Header::paintSection(QPainter * painter, const QRect & rect, int logicalIndex)...

QWidget.paintevent() vs QLabel.setPixmap()

qt,qwidget,qlabel
I am trying to grab a widget and show it in another widget. Which one is less expensive? 1- using QWidget.paintevent() void MonitoringWidget::paintEvent(QPaintEvent *event) { if (m_mirrorWidget){ QPixmap mirrorPix = m_mirrorWidget->grab(); QPainter p(this); // p.drawPixmap(this->rect(),mirrorPix,mirrorPix.rect()); p.drawPixmap(ui->mirrorFrame->geometry(),mirrorPix,mirrorPix.rect()); update(); } return; } 2- QLabel.setPixmap()? QLabel mirrorLabel; QPixmap mirrorPix = m_mirrorWidget->grab(); mirrorLabel.setPixmap(mirrorPix )...

How can I override the member of (->) operator of a base class

c++,qt,inheritance,overloading,operator-keyword
Background: I have Qt generated UI classes with no common ancestor. I am subclassing a class (say, "Door") that uses one of these UI classes, and the derived class ("OakDoor") will use a different UI class, although much of the UI elements will have the same name. Until now I...

Return const reference to local variable correctly

c++,qt
Additionally to the answers 1, 2, 3 and GotW88, assume the following methods QString createString() { return QString("foobar"); } const QString& getString() { return createString(); } This will yield the famous "warning C4172: returning address of local variable or temporary" with VS2013. Now if i changed the second method to...

Unresolved External Symbol in QT connect()

c++,qt
I´m pretty new to QT and C++ and I´m getting this error that I can´t manage to solve. I´m trying to connect the currentRowChanged() signal of the TableView selection model to a slot I created so I can get data from the row that is selected. This is my code:...

Copy text and placeholders, variables to the clipboard

c++,qt,clipboard
In my application I want generate random numbers or strings with a text in front of it. It is important for me that the text won't appear in my window, but instead gets copied to the clipboard. int randomnumber = rand() % 46 + 1; QClipboard *cb = QApplication::clipboard(); cb->setText("Just...

qmake cannot find file

osx,qt
System: Mac OSX Yosemite. I installed qt 4.8.7 from homebrew, and then went to a directory I cloned from github (MagRead @ https://github.com/ieatlint/MagRead.git). I ran: qmake MagRead.pro and got this error: Cannot find file: magread.pro. But the file is clearly in the directory! I googled and found one similar question...

QEvent ownership

c++,qt,memory-management
I want to send both predefined and custom QEvent to a Qt application. Is the event required be allocated on the heap or can I just pass the pointer to a object on the stack? QKeyEvent stackevent(QEvent::KeyPress); QKeyEvent* heapevent = new QKeyEvent(QEvent::KeyPress); QEvent * event; event = &stackevent; //valid ??...

Why is BUILD FAILED?

android,qt,qt-creator
I am trying to run simplest Qt application on android device. There are AVD and real phone with android. For both of them I get error: BUILD FAILED /home/user1/dev/android-sdk-linux/tools/ant/build.xml:649: The following error occurred while executing this line: /home/user1/dev/android-sdk-linux/tools/ant/build.xml:655: Execute failed: java.io.IOException: Cannot run program "/home/user1/workspace/build-Test11123-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_2-Debug/android-build/${aidl}": error=2, No such file or...

How to prevent a user from moving the size of a column in QtableWidget using Python and Qt?

python,qt,qt-creator,qtablewidget
I created a QTableWidget whith two columns in Qt Creator. I already found out how to set the width of a column with the setColumnWidth() function. But in my GUI the user can still change the width of columns. How can I set the width to a fixed size and...

Qstring error. Saving from Textpool to string

c++,qt,qstring
I've been trying to make simple 'typing game' where program is checking if input = showcased word. I'm trying to use Qt GUI, so I've placed two text widgets, and "play" button. However, there is a problem with string (or QString). Error: no match for 'operator=' (operand types are 'QString'...

Adding an image to the Qt toolbar area

c++,qt,toolbar
I was making a Qt application and after placing my actions, still a lot of empty space is left in the toolbar. I was trying to add an image to the right side of icons, and was told it is possible using QLabel object and placing an image using QPixmap....

QTabWidget tab displays nothing in one of the tabs

c++,qt,user-interface,qwidget,qtablewidget
I am trying to create a gui that has a QTabWidget with multiple tabs. As a preliminary test I have created one that has two tabs using the same layouts. The first tab (Page 1) is blank but then the second one shows the QTableView I created. Both tabs were...

How can I have an animated system tray icon in PyQt4?

python,qt,pyqt,pyqt4,system-tray
I am trying to create an animated systray icon for a pyqt4 app but am having trouble finding any examples in python. This is the closest I can find but it's in C++ and I don't know how to translate it over: Is there a way to have (animated)GIF image...

Deploying to Android results in file not found after adding QtQuick Controls

android,qt,deployment,qml,qt5.4
After importing QtQuick.Controls 1.2 and using StackedWidget component, I now get an error when deploying to Android as seen below. The missing file AnimationDrawable.qml is not missing from the Android build directory so I do not understand why it is not packaged with the APK. It deploys fine when I...

Sorting based on the rules set by a string variable

c++,qt,sorting,c++11
In my hypothetical app, I receive a list of hotels from the server. struct Hotel { std::string name; // e.g. Hilton, Ritz int stars; // In range [0..5], 0 stands for "unrated" int freeRoomCount; // Number of available rooms [0..N] int parkingPlacesAvailable; // Number of parking places availalble [0..M] }...

load a thumbnail on QListWidget with reduced resolution

image,qt,qlistwidget,qlistwidgetitem
I need to reduce the resolution of the images that I add and show in a QListWidgtet. Now I use the next code but it does not show all the images because they are being loaded with full resolution void ImagesWizard::on_pbAddImages_clicked() { QFileDialog dialog(this); dialog.setDirectory(mInitPath); dialog.setFileMode(QFileDialog::ExistingFiles); dialog.setNameFilter(trUtf8("Images (*.jpg *.png *.tif...

trying to get a running time stamp on Qt

c++,qt,while-loop
I am trying to keep a running time stamp every so many milliseconds. This will eventually be attached to a temperature reading. Right now the time stamp is only displaying after the rest of my program has run and I need it to populate in real time. My updated code...

How to differentiate a QNetworkReply is aborted or not?

c++,qt,networking
I have the following code: connect(&netMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(loadFinished(QNetworkReply*)), Qt::UniqueConnection); reply = netMgr.get(qheader); How could I tell whether the loadFinished(); slot is triggered by calling reply->abort() or not?...

Qt - QScrollArea - align added widgets to top

c++,qt,qscrollarea
I have a 150x450 QScrollArea with a VBoxLayout in it. I have to dynamically (while a video is being played, frame by frame) add an unspecified amount of QLabels, ranging from none to hundreds. When I start adding, QLabels start appearing exactly in the middle. Then when another appears, they...

C++ : How to use SAPI with QT Creator?

c++,qt,sapi
I've got to do a project who consist to create a web browser including a Text To Speech solution. I've used examples from the MSDN (here), but when I try to compile my project, i've got a lot of errors, and I haven't found any solutions... I'm using QT Creator...

How can I make a QTextEdit widget scroll from my program

c++,qt
I have a QTextEdit widget with a vertical scroll bar. report_text = new QTextEdit(); report_text->setAcceptRichText(true); report_text->setReadOnly(true); report_text->setTextInteractionFlags(Qt::NoTextInteraction); report_text->setAlignment(Qt::AlignTop); report_text->setWordWrapMode(QTextOption::NoWrap); report_text->setFrameStyle(QFrame::NoFrame); report_text->setMinimumSize(600, 380); report_text->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); This is Qt 4.8 embedded. Now I...

QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error

c++,sql-server,qt,tsql,odbc
I get this error when I try to call stored procedure in QT using QODBC: QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error Amount of parameters is correct, syntax looks alright to me. The procedure executes fine in Management Studio. What might be the...

QtQuick2 - QML reusable item focus changes when selecting/clicking outside/inside of root item

javascript,qt,focus,qml,qtquick2
How can I implement focus changing state into reusable QML component when I clicked or selected another item outside component body to call any event (highlight text, show/hide rectangle and etc). There is code I trying to implement highlight line under CheckBox text when item have focus, and hide that...

Is there a way to prevent Qt slider dragging beyond a value?

qt,qslider
I have implemented the interface where the user is drawing a frame and then moving to next frame which will increment the slider value by 1. User can also increment or decrement the slider value. But, if user has drawn only upto frame 20 then user should not be able...

change QDir::rootPath() to program running path?

c++,qt
I have a Qt FTP server that selects C:/ as root path. I'm trying to change that to select the starting program location path. For example: If ftpserver.exe is located in H:/programs/ftpserver.exe, it must automatically set the ftp root path to H:/. Code: ui->lineEditRootPath->setText(settings.value("settings/rootpath", QDir::rootPath()).toString()); Code: void MainWindow::on_toolButtonBrowse_clicked() { QString...

How to rotate an element on both axes with different angle values

qt,qml
If you need to rotate an element in QML in order to achieve a sort of 3d flip effect then you can do transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 24 } How can I achieve the same thing but...

Undefined symbols for architecture x86_64: “_CFBundleCopyResourceURL”,

c++,qt,app-bundle,cfurl-encoding
Trying to access the file path to the resources folder in a Mac .app bundle using Qt. Here's my code: CFURLRef appUrlRef; appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("AFE-MP-512"),NULL,NULL); CFStringRef filePathRef = CFURLCopyPath(appUrlRef); qDebug() << filePathRef; // Release references CFRelease(filePathRef); CFRelease(appUrlRef); The only thing I have is a pushbutton on the form to...

Using Py2app with a GUI from QT Creator

python,qt,user-interface,pyqt,py2app
I created a GUI in QT Creatro and stored this as a *.ui file. Using PyQT I made a GUI that works fine when it is launched as $ python pyapp.py In order to build this app into something that can be executed by double clicking on it, I used...

C++ & Qt: Random string from an array area

c++,arrays,string,qt,random
In my small Qt application, I want to pick a random string out of an array after I clicked on a button. I've read many threads but nothing works for me. So in my slot there's an array with several strings in it. I also implemented <string>, <time.h> and srand....

Id in database using qt

database,qt,sqlite
I am new to qt. I have created a table in sql, and what I'm trying to do is to give an id whenever user adds data. For the first thing inserted it will be 1, second 2 and so on. So how to check what number was the last...

How to manipulate multiple Folders/Dir in QT?

c++,qt,qmediaplayer,qdir,qfileinfo
I want to know how to manipulate directories until I get video files. Firstly the main Directory is "F:/TestingVideos/" Inside the test video there are files e.g:1. Cash Office ,2.Rosville Gate ,3. My Videos Each of this videos holds other folders for example Cash Office has a Directory of "F:/TestingVideos/Cash...

QSqlQueryModel complains that my database is not open

c++,sql,database,qt,postgresql
I am trying to use QSqlQueryModel in order to retrieve some values from my database like such: QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL", "test1"); db.setHostName(Vars::strDbHost); db.setDatabaseName(Vars::strDbName); db.setPort(Vars::strDbPort); db.setUserName(Vars::strDbUsername); db.setPassword(Vars::strDbPassword); db.open() QSqlQueryModel model; model.setQuery(QString("SELECT * FROM users WHERE login=%2").arg(Vars::strUserLogin)); But I keep getting a QSqlQuery::exec: database not open error. Why is this, and...

Loading animated gif data in QMovie

json,qt,pyside,animated-gif
I'm very new to Qt (specifically PySide) and I'm trying write a script that loads an animated gif from file into a QByteArray and then into a QMovie. The reason for going from file to the QByteArray is because I cannot keep that gif file in memory. I want to...

Repeat state on mouse click QML

qt,qml,qtquick2
Within the code I have a State, a Transition and a RotationAnimation defined. After the property change takes place, i.e. after the rotation is set to 360, the onClicked handler is rendered mute and the animation will never be played again after subsequent MouseArea clicks. Here is my current code:...

std::ostream to QString?

c++,qt,exception
Is there a way to convert an std::ostream to a QString? Allow me to expand in case it is useful: I am writing a program in C++/Qt and I used to (not) deal with / debug exceptions by just using std::cout, as in for example: std::cout << "Error in void...

Qt programs (Canopy GUI, ipython qtconsole) crash in Enthought Canopy Win7 64Bits

python,qt,pyside,enthought,canopy
I installed Canopy 1.5.2 on Windows 7 - 64 Bits. I performed all steps described on Enthought web page, but Canopy GUI won't to start. I realized that the problem is something related with Qt, because applications that don't need such programs (like Mayavi, Pylab, etc) work perfectly. When I...

How can I wrap text in QGraphicsItem?

qt,text,word-wrap,qgraphicsitem
1) How can I wrap text in a QGraphicsTextItem to fit a fixed rectangle, with width and height ? Right now I am experimenting with creating a text, getting its bounding rectangle, and resizing it to fit the box - but I can't get wrapping. class TTT: public QGraphicsTextItem {...

Is there any way to skip macro replacement(During preprocessing) when macro is used as a variable name?

c++,qt,c++11,macros,qt5
ConflictHeader.h #define _c 6 //This is third party header, canot change, since // there is no sorce code to rebuild testclass.h #ifndef TESTCLASS_H #define TESTCLASS_H #include <QObject> #include "ConflictHeader.h"//Include conflicted header class TestClass : public QObject { Q_OBJECT public: TestClass(QObject *parent); ~TestClass(); private: }; #endif // TESTCLASS_H testclass.cpp #include "testclass.h"...

Qt Creator doesn't display QML folder

qt,qml,qt-creator,qtquick2,qt-quick
I have a Qt project in Qt Creator. I have a qrc file with the QMLs registered and everything works. However for some reason the "projects" view of Qt Creator doesn't show the QML folder (screenshot attached) like it does for any example project. I'm just curious. Why does QML...

QT Combo Box of Line Pattern

c++,qt,qcombobox
i want to make a line pattern combo box in Qt same as it is shown in the picture , please tell me is it possible to make a combo box in Qt like shown in the picture. Any help would be appreciated Regards ...

Maya PySide: Maya crashes when I try to connect custom signal to slot

qt,signals,pyside,maya,slot
I'm about 2 weeks into PySide and I'm loving it, but I'm having trouble understanding some of the more intermediate concepts. Any help would be greatly appreciated. I'm trying to get a few custom QEvents working in PySide with QLineEdit and QCompleter. I'm using the old style for signal/slot connections...

Build custom library without header dependency

c++,qt
I made a small application in Qt, for sending and receiving messages from/to a RabbitMQ broker. I made a library containing a RabbitMQ publisher and consumer, which in turn uses the AMQP library here. Now everytime I need to use this library in an application, I need to copy the...

Template cast operator when T is QPointF

c++,qt,templates,casting
I have a custom two dimensional point type, which has a template cast operator: struct MyPoint { double x, y; template < typename T > operator T() const { return T{ x, y }; } }; All works fine for std types: auto p1 = MyPoint{ 1, 2 }; auto...

Must compile Opencv with Mingw in order to use in QT under Winodws?

qt,opencv,mingw
I've visit these blogs https://zahidhasan.wordpress.com/2014/08/19/qt-5-3-1-64-bit-mingw-windows/ How to link opencv in QtCreator and use Qt library http://www.cnblogs.com/grandyang/p/4328896.html All of them are using Mingw to compile Opencv through Cmake. If I want to use Opencv in QT, is compiling with Mingw the only way? I have this question because I already compiled...

Qt Regular Expression selects from first of first match to end of last match

regex,qt,qregexp
I'm using QRegExp for geting some directories in a file. All of them start with "R:/ and finish with .c". So I used "R:/(.*).c" regex statement. But it has 1 match for below text : Text : mov f1, dsa lis r9, sdefwf "R:/frori.c" addi r3, r9, cwrfg "R:/DWors.c" li...

Even width of Text and Textfield

qt,qml,qt5,qtquick2
I have a simple login form written in QML with a custom component, MediumText, and two TextFields. Unfortunately, I'm not able to properly align the elements, as shown by the following picture: I want the labels to the left (MediumText type), as well as the TextField instances on the right,...

Crash cause of own template

c++,qt,templates,crash,qvector
why is my program crashing when I use my template? What I'm doing wrong? That's a test program, because the actual program is too big for posting here. The first qDebug with test1 are displayed but the second not. #include <QCoreApplication> #include <QDebug> #include <QMutex> class MutexLocker { public: MutexLocker(QMutex&...

Updating ac value for Qtimer

qt,user-interface,adc
I am using qt tool for mini2440. I make a gui for i2c adc having starti2c and stopi2c. All things are working well: it reads value of signal when starti2c button press, but I want this value to be updated. I know that Qtimer can be used, but how can...

Align horizontalcenter in Column

qt,qml,qtquick2,qt-quick
Column documentation explains how to achieve this: However, I would like to achieve this: That is, all items inside the Column should be horizontally aligned to the center. anchors.horizontalCenter: parent.Center does not work. How can I obtain the desired result?...

where and what to learn to use Qt5? [closed]

c++,qt,qml
I tried to use Qt5 but I find it very confusing. I have good knowledge of c++(I would say between intermediate-expert level) but no knowledge of javascript or QML(only basic HTML) When I go through the examples and tutorials provided with Qt, I find then more to be reference material...

Qt - easiest way to convert int to file size format (KB, MB or GB)?

qt
What is the easiest way to convert int of file size to string in file size format like: 2048 to 2 KB 4086 KB to 4 MB instead of calculating it manually in Qt5?...

Using QSimpleXmlNodeModel and QTreeView

c++,qt
I've been looking at ways to populate a QTreeView with data from an XML file. The XML will be simple. I've come across QSimpleXmlNodeModel and have been trying to figure out if this is suitable for my needs, but can't find any examples of its use. Can someone point me...

connecting signals and slots with different relations

c++,qt,connect,signals-slots
First of all I'd say I'm a noob to GUI programming. I use Qt 5.4. I came up with this code while watching voidRealms videos. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),ui->progressBar,SLOT(setValue(int))); Obviously this connects slider movement with progressbar fill. This actually works like progressbarfill <- slidermovement. How can I make into a different relation? Like...

Pro file directive: copy target to folder at build step

qt,qt5
I have a TEMPLATE = subdirs project with 6 subprojects which build in specified order. I would like to copy the output file of project1 (it's target) to some folder. This folder is passed with LIBS += -L to project2 and project2 may use this file as a static library....

Fit the width of the view to longest item of the QComboBox

c++,qt
I've got a QComboBox which contains long strings. Long means that the strings are wider than the width of QComboBox on my GUI. In this case Qt will display the items in this way: Previously I was working with MatLab which has a less user friendly GUI but for a...

QT add widget(pushbutton, textEdit, labels) to QT Designer layout programatically [closed]

c++,qt,qwidget,qlabel
Is it possible to dynamically add widgets(Push Buttons, Labels etc), into a QT Designer generated central widget layout? How can it be done? Thank You!...

Update and sort Qt ComboBoxes alphabetically

c++,qt,sorting,combobox
I want to write a program, working like a little navigation system uisng the Qt framework, but i still am very new to it. I created a dialog with two Comboboxes. Each combobox contains all "citynames". At the initialization the content of both boxes is sorted alphabetically. If a name...

Qt Cannot access *ui pointer from inheriting class

c++,qt,user-interface,inheritance,objective-c++
I am trying to write an application where I would have a generic dialog window and specific dialog windows that would inherit some basic functionalities from the generic one. I am not sure this is the best approach for this, but this is how I did it (The CGenericProject class...

Customizing QDateEdit style

c++,qt
How can i get the appearance of QDateEdit as shown on the image? I tried changing the stylesheet, but I dont know how to achieve the spacing between the button and the edit, nor how can I change the down arrow button....

How to add a gif image in the statusbar Qt [closed]

c++,qt
I'm pretty new to Qt and I was told that I can add a gif image to the status bar using the QMovie class. Can anyone tell how it can be done and is there any other way to do this too?

Qt can't assign value to QLabel

c++,qt
I like to start out saying that I'm about as noob as they come. This is my first c++ program I built from scratch. I gotten most of the bugs ironed out, however I can't seem to be able to assign a value to a QLabel. I want the function...

QML module not installed error: running Qt app on Embedded Linux

c++,linux,qt
I am trying to launch my cross-compiled GUI Qt application on a certain TI board. I use this command to launch the application: QT_DEBUG_PLUGINS=1 QT_PLUGIN_PATH=/root/qt-5.2.1-install/plugins LD_LIBRARY_PATH=/root/qt-5.2.1-install/lib/ ./simple_qml_ui -platform linuxfb Unfortunately the error occurs: QFactoryLoader::QFactoryLoader() checking directory path "/root/qt_app/styles" ... QFactoryLoader::QFactoryLoader() checking directory path "/root/qt-5.2.1-install/plugins/styles" ... QQmlApplicationEngine failed to load component...

Context Pointer Lost in FSEventStreamCreate Callback (c++)

c++,osx,qt,fsevents,file-watcher
im trying to test a simple filewatcher in mac using the FSEvent Api. I get the callback with the events and everything seems to work but i can't recover the info contained in the info field of the context structure. Here is my code: void feCallback(ConstFSEventStreamRef streamRef, void* pClientCallBackInfo, size_t...

Does a class instance thread affinity has any impact on its data?

c++,multithreading,qt
We know from QThread documentation A QObject instance is said to have a thread affinity, or that it lives in a certain thread. When a QObject receives a queued signal or a posted event, the slot or event handler will run in the thread that the object lives in. Does...

Qt5: How to replace numeric values of a column of a SQL table view with text aliases?

sql,qt,table,view,alias
I am using Qt5. I managed to connect to a sql database and using QtCreator I have now a QTableView that is nicely populated using "SELECT * ..." from a test table I previously defined with MS SQL Manager... Only one thing I would like to change: ...One column named...

Rotating a Label In Qt with Python

python,qt
I'm somewhat new to Qt and was wondering how to rotate a Label that has a pixmap inside of it. I've tried somethings like this: def paintEvent (self, event): t = QtGui.QTransform() image = QtGui.QImage(_fromUtf8(":/icons/BOOM_OUT.png")) pixmap = QtGui.QPixmap.fromImage(image) self.label.setPixmap(pixmap) t.translate(400,300) t.rotate(45) p = QtGui.QPainter(self) p.setTransform(t) p.drawPixmap((-pixmap.width()/2),(-pixmap.height()/2), pixmap) p.end() I know...

How to set User Agent in QtWebEngine QML application

qt,qml,qt5,user-agent,qtwebengine
NOTE: I was able to do that on QtWebKit QML using the QtWebView extension. Here I am interested in using QtWebEngine. My simple test application import QtQuick 2.1 import QtQuick.Controls 1.1 import QtWebEngine 1.0 ApplicationWindow { width: 800 height: 600 color: "lightgray" visible: true WebEngineView { id: webview url:...

Is there an idiom like `if (Value * value = getValue())` when you branch on an expression of the retrieved value?

c++,qt,qstring
I am often using the common if (Value * value = getValue()) { // do something with value } else { // handle lack of value } Now, I also often do QString error = someFunctionReturningAnErrorString(arg); if (!error.isEmpty()) { // handle the error } // empty error means: no error...