Menu
  • HOME
  • TAGS

Template cast operator when T is QPointF

c++,qt,templates,casting

As far as I can tell the issue is that QPointF provides a constructor which takes a QPoint. When you do a static_cast the compiler tries to call QPointF(MyPoint&) and it sees two ways to create a QPointF from MyPoint: Use the constructor taking a QPoint, by converting MyPoint to...

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

qt

QFileInfo doesn't have a method specific for that, but here you can find a simple implementation subclassing QFileInfo and implementing this new method QString QFileInfoHumanSize::size_human() { float num = this->size(); QStringList list; list << "KB" << "MB" << "GB" << "TB"; QStringListIterator i(list); QString unit("bytes"); while(num >= 1024.0 && i.hasNext())...

Update bindings to var properties in QML

qt,qml

Actually, the page does say how to work around this: If the onCompleted handler instead had "car = new Object({wheels: 6})" then the text would be updated to say "The car has 6 wheels", since the car property itself would be changed, which causes a change notification to be emitted....

Can't create QList with custom class

c++,qt,qlist

...\user.h(13) : error C2065: 'Read' : undeclared identifier Looks like Read is not known in user.h. Maybe date.h or book.h are including user.h as well? (circular references) Using prototype classes can help to prevent this....

QDateTime Conversion

qt,qdatetime

Your date string does not include a time, while you mentioned that you want one, this will fail at least in Qt 5.4 . I don't know though why you get the epoche outputed, maybe that is dependant on your Qt version. Your date format is also locale dependent. See...

QFrame with background image and otherwise transparent background

c++,qt,background-image,qframe

This code works for me (tested under MacOS/X 10.10.3, using Qt 5.5.0-beta; I'd expect it to work under any Qt version 4.5.0 or higher though): main.h: #ifndef main_h #define main_h #include <QFrame> #include <QPixmap> class MyFrame : public QFrame { public: MyFrame(QWidget * parent); virtual void paintEvent(QPaintEvent * e); private:...

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

c++,qt,qpainter,qheaderview

It is obvious why the first fillRect doesn't work. Everything that you paint before paintSection is overridden by base painting. The second call is more interesting. Usually all paint methods preserves painter state. It means that when you call paint it looks like the painter state hasn't been changed. Nevertheless...

QTabWidget tab displays nothing in one of the tabs

c++,qt,user-interface,qwidget,qtablewidget

Read logs! I'm sure you have a respective warning. You are assigning same layout to two different widgets. Once layout is assigned to a widget, it is owned by this widget forever. You need create separate layout for each widget. I recommend to split this onto couple methods. One is...

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

python,qt,qt-creator,qtablewidget

Use table.horizontalHeader().setSectionResizeMode(...) (or setResizeMode in older Qt versions) with appropriate resize mode.

connecting signals and slots with different relations

c++,qt,connect,signals-slots

You need to create new slot for that purpose. But in C++ 11 and Qt 5 style you can use labmdas! It is very comfortable for such short functions. In your case: connect(ui->horizontalSlider, &QSlider::sliderMoved, this, [this](int x) { this->ui->progressBar->setValue(x / 2); }); ...

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

regex,qt,qregexp

The * operator is usually greedy in Qt Regexp. You can change this by calling setMinimal(true) Greedy regexps try to consume as much as possible, and therefore behave exactly as you are experiencing. Minimal Regexps try to match as little as possible. This should solve your problem, as the matching...

Qstring error. Saving from Textpool to string

c++,qt,qstring

http://doc.qt.io/qt-4.8/qlineedit.html#text-prop textChanged is a signal that you can send when the text changes Use QString text() const instead Another useful method: modified : bool to check if the text was modified by the user Update to answer additional comment questions: It is best to declare all variables as private. Add...

Unresolved External Symbol in QT connect()

c++,qt

In Opciones.cpp you haven't declared filaSeleccionada to be scoped within the Opciones class. Declare it this way: void Opciones::filaSeleccionada(const QModelIndex & current, const QModelIndex & previous){ } What you've done in your code is to declare a new free function, filaSeleccionada. The compiler has no problem with this, as it...

Using Py2app with a GUI from QT Creator

python,qt,user-interface,pyqt,py2app

This is happening because py2app would not be able to find files specified through string paths in the code. It will not include those files in the binary. You can do one of two things to solve your problem. 1) You have to convert your .ui file to .py file...

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

c++,qt,qstring

The only way to use that idiom while still keeping your code understandable is if your function returns an object that is convertible to bool in a way that true indicates that you want to take the branch and false means that you do not care about it. Anything else...

Crash cause of own template

c++,qt,templates,crash,qvector

Add this method: T & r() { MutexLocker m(*_mutex); Q_UNUSED(m); return _r; } Explanation: T r() const returns a copy of r_. Which is destroyed then. While actual r_ is not modified here test2.r().resize(10);. And later on....

Cmake and Qt5 linking error

c++,qt,cmake,qt5

I think you forget to append moc and resources to your executable use qt5_wrap_cpp() for mocs use qt5_add_resources() for resources. Then you must append vars to add_executable check out this link. ...

How to differentiate a QNetworkReply is aborted or not?

c++,qt,networking

If aborted, QNetworkReply::error() should return QNetworkReply::OperationCanceledError, which means: the operation was canceled via calls to abort() or close() before it was finished. ...

Context Pointer Lost in FSEventStreamCreate Callback (c++)

c++,osx,qt,fsevents,file-watcher

The problem was unrelated to this code. The pointer works fine but his object was lost.

Cannot connect (null)::selectionChanged to QTableView

c++,qt,qt-creator,signals-slots,qtableview

The signal slot connection has failed since table->selectionModel() has returned null. If you set the model for your table before making signal slot connection, table->selectionModel() will return a valid model, making the signal slot connection successful....

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

c++,qt,qwidget,qlabel

Of course, and it's quite easy. You can have a look at the ui_mainwindow.h at the debug/release dir. I prefer setting layouts for widgets in QtDesigner to the code. It's something like this: //set layout programatically auto layout = new QHBoxLayout(ui->centralWidget()); //or if you have set horizontalLayout in Qt Designer...

DPI-independent constant size in QML

qt,qml,qt5,qtquick2,qt-quick

Well, I've just might've found a solution: Screen.pixelDensity. But feel free to suggest anything better.

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

javascript,qt,focus,qml,qtquick2

Bind highlightLine.visible to root.activeFocus so the highlight only shows when the checkbox gains active focus: Rectangle { id: highlightLine //... visible: root.activeFocus } The active focus can be set in many ways. For example, when user clicked the checkbox: MouseArea{ id: bodyArea onClicked: { //... root.forceActiveFocus(); //set root's active focus...

Confusion with std::pairs initialization

c++,qt,hash,unordered-map,std-pair

I don't know anything about QT, but if QHash is anything like unordered_map, then the issue is where you're using operator[]. That function will insert a default-constructed value for a given key if it doesn't exist. In order to do that, the value-type must be default constructible, and: std::pair<const ParticipantNode&,...

Compiling a Qt Application using Dev C++ on Windows

c++,qt,dev-c++

Dev-C++ is based on mingw, so you should install Qt compiled for mingw on Windows. Then indeed you should use qmake to generate Makefiles. For compilation you should use the make utility provided by mingw distribution shipped with Dev-C++ (the name of this utility might not be exactly 'make' in...

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

c++,qt

You can add a QLabel, with a QMovie in it. QLabel label; QMovie *movie = new QMovie("animations/fire.gif"); label.setMovie(movie); movie->start(); You can then add the label to the using QStatusBar::addWidget() like so: statusBar()->addWidget(&label); ...

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

python,qt,pyqt,pyqt4,system-tray

Maybe something like this. Create QMovie instance to be used by AnimatedSystemTrayIcon. Connect to the frameChanged signal of the movie and call setIcon on the QSystemTrayIcon. You need to convert the pixmap returned by QMovie.currentPixmap to a QIcon to pass to setIcon. Disclaimer, only tested on Linux. import sys from...

Build custom library without header dependency

c++,qt

You can totally do this. You do not actually need these headers (using them is just usefull) - all you really need is to declare all objects (types, functions, variables) you are actually using. So, if you have a lot of headers, but use, say, only one function, all you...

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

c++,qt,inheritance,overloading,operator-keyword

As I eventually realised above, this isn't possible. The operator ->() has to return the type upon which it is acting, and for that reason it can't be used as a virtual function.

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

c++,qt

QCoreApplication::applicationDirPath() returns the exact directory path of your app, for example H:/programs if your app path is H:/programs/ftpserver.exe so if you modify that QString you can get the root dir. For example: QString rootPath = QCoreApplication::applicationDirPath(); rootPath.chop(rootPath.length() - 3); //we leave the 3 first characters of the path, the root...

Adding an image to the Qt toolbar area

c++,qt,toolbar

The QToolbar already contains all the functionality you need. Simply user the addWidget(QWidget* method and supply a pointer to the widget (your label). QLabel* label = new QLabel(); label->setPixmap(QPixmap("...")); this->ui.toolbar->setWidget(label); ...

Updating ac value for Qtimer

qt,user-interface,adc

Hopefully this will get you started - it creates a timer which times out every 1000 milli seconds. The timer's timeout signal is connected to the same slot that your PushButton1 is connected to - starti2c. QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(starti2c())); timer->start(1000); That code should be...

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

python,qt,pyside,enthought,canopy

Usually this error means that PySide is either unable to find the Qt DLLs, or the ones it did find are not the right version and do not have some of the expected symbols. Do you have some other set of Qt libraries on your system in the PATH somewhere?...

How to set User Agent in QtWebEngine QML application

qt,qml,qt5,user-agent,qtwebengine

I'm interested in using QtWebEngine too. And I can suggest you use QtWebEngine developers Trello. As you can see in Todo for 5.5 this is currently under development and may be done in 5.5....

Return const reference to local variable correctly

c++,qt

It doesn't work. That way you simply suppress the warning by making the situation harder to analyze. The behavior is still undefined.

Find last entry in a map

c++,qt,dictionary

Use lastKey: const Key & QMap::lastKey() const Returns a reference to the largest key in the map. This function assumes that the map is not empty. This executes in logarithmic time. This function was introduced in Qt 5.2. As in: qreal last = myMap.lastKey(); ...

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

c++,qt,qt5,qtserialport

The problem is that &QSerialPort::error is ambiguous: There's the signal you're trying to connect to: QSerialPort::error(QSerialPort::SerialPortError) But then there's also a getter with the same name: QSerialPort::error() That's unfortunate design of the QSerialPort class (QProcess has the same problem), and might be fixed in Qt 6, but not before that,...

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

qt,user-interface,python-3.x,dialog,qt-creator

use setModal() like so; dialog.setModal(1); Or; dialog.setModal(true); ...

Pro file directive: copy target to folder at build step

qt,qt5

Create DestDir.pri in folder, where all of your projects located. Insert next code: isEmpty(DESTDIR) { CONFIG(debug, debug|release) { DESTDIR=$$PWD/Build/Debug } CONFIG(release, debug|release) { DESTDIR=$$PWD/Build/Release } } Include DestDir.pri to each pro file: include(../DestDir.pri) You can change DESTDIR variable to your path or set this variable via qmake command line utils...

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

c++,linux,qt

It turns out you just need to copy plugins directory from your Qt installation folder to your app folder.

load a thumbnail on QListWidget with reduced resolution

image,qt,qlistwidget,qlistwidgetitem

Use QImage first to scale the image and construct the icon from the resulting pixmap. QSize desiredSize; Qimage orig(filesToLoad[var]); Qimage scaled = orig.scaled( desiredSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QListWidgetItem *listItem = new QListWidgetItem(QIcon(Qpixmap::fromImage(scaled)),filename); It is very common to store the presized image too on the disk, to avoid the two step conversion...

How can I make a QTextEdit widget scroll from my program

c++,qt

Here is what I found as a suitable solution: The vertical scrollbar may be accessed using the QTextEdit::verticalScrollBar() method. Scrollbars have a triggerAction() method to conveniently simulate user interaction with the buttons and the slider. The available actions are defined in QAbstractSlider. So the resulting code is only a single...

Id in database using qt

database,qt,sqlite

The method you're looking for is QSqlQuery::lastInsertId(). To quote the documentation: Returns the object ID of the most recent inserted row if the database supports it. An invalid QVariant will be returned if the query did not insert any value or if the database does not report the id back....

Align horizontalcenter in Column

qt,qml,qtquick2,qt-quick

I suppose you can use anchors.horizontalCenter for all the child items to align them with the horizontalCenter of the column given that the column has an id you can refer to.

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

c++,qt

Here is the most direct, but hardcoded way. #include "widget.h" #include <QLabel> #include <QFont> Widget::Widget(QWidget *parent) : QWidget(parent) { QSize frameSize = this->frameGeometry().size() - this->geometry().size(); this->resize(frameSize + QSize(250, 125)); QLabel * label = new QLabel(this);// parenting instead of layouts label->resize(130, 32); label->move(60, 40); QFont f = label->font(); f.setPointSize(16); label->setFont(f); label->setText("Sample");...

How can I wrap text in QGraphicsItem?

qt,text,word-wrap,qgraphicsitem

You did not specify Qt version but try: void QGraphicsTextItem::setTextWidth(qreal width) Sets the preferred width for the item's text. If the actual text is wider than >the specified width then it will be broken into multiple lines. If width is set to -1 then the text will not be broken...

How to change the opacity of Qt MainWindow?

qt,qmainwindow

The below works for me most of times (as long as we can run in stylesheet override problem with other ways). Consider change the last component of rgba to less than 255 for making it semi-transparent. widget->setStyleSheet("background-color: rgba(255, 255, 255, 255);"); Mind that child widgets may inherit the transparent background...

qmake cannot find file

osx,qt

File names are case sensitive. Try qmake magread.pro Or just this, if directory name is also magread or if there is just one .pro file in current directory: qmake ...

Repeat state on mouse click QML

qt,qml,qtquick2

States are a way to represent different property configurations for a given Item. Each State has its unique set of values for the properties defined inside the specific Item. Transitions are a way to add animations to an Item when the current State changes to another State. They can be...

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

c++,arrays,string,qt,random

You should use the random header. #include <random> std::default_random_engine generator; std::uniform_int_distribution dist(0, 5); int StringIndex = dist(generator); std::string ChosenString = characters[StringIndex]; The above will generate a random index into your array. If you want to limit the range, change the constructor of dist, for example (dist(0,2) would only allow for...

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

qt,qml

The transform property of Item is a list, so you can apply multiple rotations: import QtQuick 2.3 import QtQuick.Window 2.2 Window { visible: true width: 200 height: 200 Rectangle { width: 100 height: 100 anchors.centerIn: parent color: "red" transform: [ Rotation { origin.x: 30; origin.y: 30; axis { x: 0;...

How to pass QString variable to QFile?

qt,qstring,qfile

QString selected = model2->filePath(index); does not set the variable in the (maybe same named) member OptionsDialog::selected. This creates a new local variable. If you have a member variable called selected then you should use it like this: void OptionsDialog::getData(const QModelIndex &index) { selected = model2->filePath(index); ... } ...

Undefined symbols for architecture x86_64: “_CFBundleCopyResourceURL”,

c++,qt,app-bundle,cfurl-encoding

You need to link with the CoreFoundation framework. You can add the following to your qmake project: LIBS += "-framework CoreFoundation" ...

Why is BUILD FAILED?

android,qt,qt-creator

I had the same problem. Adding these lines to build.xml file solved it: <property name="aidl" location="${sdk.dir}/build-tools/22.0.1/aidl${exe}" /> <property name="aapt" location="${sdk.dir}/build-tools/22.0.1/aapt${exe}" /> <property name="dx" location="${sdk.dir}/build-tools/22.0.1/dx${exe}" /> <property name="zipalign" location="${sdk.dir}/build-tools/22.0.1/zipalign${exe}" /> ...

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

qt,qslider

Use this class and just set setRestrictValue() that is the minimum value that user can drag the slider slider.h #ifndef SLIDER_H #define SLIDER_H #include <QSlider> class Slider : public QSlider { Q_OBJECT public: Slider(QWidget * parent = 0); ~Slider(); void setRestrictValue(int value); private slots: void restrictMove(int index); private: int m_restrictValue;...

Update and sort Qt ComboBoxes alphabetically

c++,qt,sorting,combobox

You're trying to use QComboBox's internal model as source model for proxy. This is not going to work because QComboBox owns its internal model and when you call QComboBox::setModel, previous model is deleted (despite you reset its parent). You need to create a separate source model. Conveniently, you can use...

QT-FTP Upload Error

c++,qt,ftp,qnetworkreply

I can't get, why do you use QNetwork instead awesome QFtp module, that provides all necessary for work with ftp? QFtp *ftp = new QFtp(parent); ftp->connectToHost("f13-preview.125mb.com"); ftp->login("1896230", "mypassword"); and then use QFtp::put. That's all you need....

Loading animated gif data in QMovie

json,qt,pyside,animated-gif

This looks like a PySide bug, as the same code works perfectly fine in PyQt. The bug seems to be in the QMovie constructor, which does not read anything from the device passed to it. A work-around is to set the device explicitly, like this: import sys from PySide import...

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

android,qt,deployment,qml,qt5.4

When deploying the application, androiddeployqt will copy a bunch of files which terribly fails on Windows when source or destination paths become longer than 260 characters (yeah, that's a "known feature"). Keeping the Qt installation and the project directory as top level as possible helps to reduce the path lengths...

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

qt,signals,pyside,maya,slot

I think my problem was related to the style in which I was connecting the signal and slot. I found this great post that walks you through the new style. I created a few variables before the MyLineEdit's constructor. Then I used those variables in the tab_event function. Then I...

How to rename qrc file?

visual-studio,qt

There is need to edit Q_INIT_RESOURCE argument. int main(int argc, char *argv[]) { Q_INIT_RESOURCE(mdi); ...

QtWidget Disable Margin for overlay widget

c++,qt,c++14,qwidget

Had an error in my paint-Routine for SudokuFieldWidget which caused this misbehaviour... m_markerOverlay->setGeometry( this->geometry() );

QSqlQueryModel complains that my database is not open

c++,sql,database,qt,postgresql

You are calling the wrong version of setQuery. This only works with db which have the default name. In your case, you need to call void QSqlQueryModel::setQuery(const QString &query, const QSqlDatabase &db): model.setQuery(QString("SELECT * FROM users WHERE login=%2").arg(Vars::strUserLogin) , db); ...

Qt Creator doesn't display QML folder

qt,qml,qt-creator,qtquick2,qt-quick

You need to add them to your .pro file (if I'm not wrong it's enough to append them to DISTFILES).

Even width of Text and Textfield

qt,qml,qt5,qtquick2

You can use a GridLayout instead of building a grid by means of ColumnLayout and RowLayout. By using the GridLayout, what you want is already guaranteed by the component. Here is a full example from which you can start: import QtQuick 2.3 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts...

Qt can't assign value to QLabel

c++,qt

The issue is with following signal slot connection. QObject::connect(calculate, SIGNAL(clicked()), &prog, SLOT(results->setNum(value(*spinner));)); You are trying to connect the clicked() signal of calculate button to results->setNum(value(*spinner)); slot of prog. But results->setNum(value(*spinner)); is not actually a slot. A slot is simply a method in a class that inherits QObject. Method should be...

Sorting based on the rules set by a string variable

c++,qt,sorting,c++11

You can make a map between their choice and a functor to sort by, for example using SortFun = bool(*)(Hotel const&, Hotel const&); std::map<char, SortFun> sorters { {'s', [](Hotel const& lhs, Hotel const& rhs){ return lhs.stars < rhs.stars; }}, {'f', [](Hotel const& lhs, Hotel const& rhs){ return lhs.freeRoomCount < rhs.freeRoomCount;...

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

c++,qt,qml

I have developed a few Qt applications and to this day no knowledge whatsoever about qml. It definitely is the new way because it is newer than what you're after but if everything will be done in qml in Qt 6 or 7 I have no idea. So to answer...

QT Combo Box of Line Pattern

c++,qt,qcombobox

Easy way: comboBox->setIconSize(QSize(100, 24)); comboBox->addItem(lineIcon, ""); comboBox->addItem(dotLineIcon, ""); comboBox->addItem(dashLineIcon, ""); ... Correct way: comboBox->setItemDelegate(...); ...

Copy text and placeholders, variables to the clipboard

c++,qt,clipboard

You're not using the function setText correctly. The canonical prototype is text(QString & subtype, Mode mode = Clipboard) const from the documentation. What you want to do is assemble your QString ahead of time and then use that to populate the clipboard. QString message = QString("Just a test text. And...

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

c++,qt,sapi

This is probably the most simplistic example I can think of that will work for MSVC. I don't imagine it would be too much more different for QT Creator. #include <sapi.h> #include <sphelper.h> #include <conio.h> int main(int argc, char *argv[]){ HRESULT hr = S_OK; CComPtr<ISpVoice> cpVoice; ::CoInitialize(NULL); hr = cpVoice.CoCreateInstance(CLSID_SpVoice);...

Qt - QScrollArea - align added widgets to top

c++,qt,qscrollarea

Having hundreds of labels in the application and layouting them in your scroll area will cost you much memory and performance. From the other hand Qt has the number of dedicated classes to handle multiple items in a scroll area such as: QTableWidget, QListWidget, QTableView etc. All these classes designed...

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

qt,opencv,mingw

You can compile it with Visual Studio as well. The opencv includepaths already have the opencv2 part of it. So the correct includepath would only be: C:\\opencv2.4.11\\opencv\\build\\include ...

Qt OpenGL transform feedback buffer functions missing

c++,qt,opengl,transform-feedback

It turned out that I never actually extended my class to use QOpenGLFunctions_4_3_Core, and it was instead just QOpenGLFunctions. Changing it to the former solved the problem.

Change attribute value of an XML tag in Qt

c++,xml,qt

I guess, but I think your XML is only present in your memory. You have to trigger somethink like tsFileXml.WriteToFile(filename) to store your changes to a file on your filesystem.

How to manipulate multiple Folders/Dir in QT?

c++,qt,qmediaplayer,qdir,qfileinfo

If i understood correctly you want something like this: My code is a bit rough but you can use it as starting point: -MainWindow.h: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QComboBox> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent =...

Qt Cannot access *ui pointer from inheriting class

c++,qt,user-interface,inheritance,objective-c++

You have to add the line #include "ui_cgenericproject.h" to the CEisProject.cpp file. The CGenericProject.h file is included in CEisProject.h, but CEisProject.h does not have access to CGenericProject.cpp. In the header of your base class you have a only forward declaration of Ui::CGenericProject, and you include its file in the .cpp....

QWidget.paintevent() vs QLabel.setPixmap()

qt,qwidget,qlabel

I would override MonitoringWidget::paintEvent() and then use the monitored widget's QWidget::render() to render the monitored widget into the MonitoringWidget. This should roughly be equivalent to what the widget being monitored itself will do when it receives paint events. Also you probably need some link between the monitored widget and the...

Using QSimpleXmlNodeModel and QTreeView

c++,qt

There is an example delivered with Qt. Take a look at xmlpatterns/filetree example. It is not that easy as with some other models. You have to implement these abstract methods: QUrl QAbstractXmlNodeModel::documentUri(const QXmlNodeModelIndex &) const QXmlNodeModelIndex::NodeKind QAbstractXmlNodeModel::kind(const QXmlNodeModelIndex &) const QXmlNodeModelIndex::DocumentOrder QAbstractXmlNodeModel::compareOrder(const QXmlNodeModelIndex &,const QXmlNodeModelIndex &) const QXmlNodeModelIndex QAbstractXmlNodeModel::root(const...

Attempting to read stdout from spawned QProcess

qt,signals-slots,qprocess

Issue is in statement QObject::connect(console_backend, SIGNAL(console_backend ->readyReadStandardOutput()), this, SLOT(this->receiveConsoleBackendOutput())); It should be QObject::connect(console_backend, SIGNAL(readyReadStandardOutput()), this, SLOT(receiveConsoleBackendOutput())); ...

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

osx,qt,escaping

On OS X, the name of a file at the level of the APIs is different from the display name that is shown to the user in the Finder, open and save panels, etc. At the level of the APIs, file names simply can't contain slashes. They are reserved for...

QEvent ownership

c++,qt,memory-management

event = &stackevent; //valid ?? Usually that's not safe, but in this case it's valid, because the function notify won't return, untill the event is handled (or not) by someone (it means that stackevent will be "alive" during this operation). delete heapevent; //valid? or lost ownership? Yap, that's valid...

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

c++,qt

I've done that few years back. Should be working fine. //determinge the maximum width required to display all names in full int max_width = 0; QFontMetrics fm(ui.comboBoxNames->font()); for(int x = 0; x < NamesList.size(); ++x) { int width = fm.width(NamesList[x]); if(width > max_width) max_width = width; } if(ui.comboBoxNames->view()->minimumWidth() < max_width)...

trying to get a running time stamp on Qt

c++,qt,while-loop

The reason the UI isn't updating is that you never cede control to the event loop, so the main thread doesn't have a chance to update the UI until after your code has executed. There's two possible solutions here: Move your existing code to a background thread that fires a...

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

c++,sql-server,qt,tsql,odbc

The problem turned out to be the syntax, I changed it to query.prepare("{CALL add_syllabus_line (:teacher_name, :subject_name, :temporary_name, :type_name, :activity_name, :min_score, :max_score, :max_score_exists, :evaluation_by_exam)}"); QComboBox *combo = static_cast<QComboBox*>(table->cellWidget(i,0)); query.bindValue(":teacher_name", teacherName); query.bindValue(":subject_name", "Физика"); query.bindValue(":temporary_name", ratingName); query.bindValue(":type_name", combo->currentText());...

Rotating a Label In Qt with Python

python,qt

Not 100% sure what you're trying to achieve, but rotating the image / pixmap and leaving the label's paintEvent unchanged seems easier: # load your image image = QtGui.QPixmap(_fromUtf8(":/icons/BOOM_OUT.png")) # prepare transform t = QtGui.QTransform() t.rotate(45) # rotate the pixmap rotated_pixmap = pixmap.transformed(t) # and let the label show the...

passing a current time variable

c++,qt,qtimer

If I got your problem right, you just have minutes variable instead of a seconds. Just change "hh:mm:mm" to "hh:mm:ss" void noheatmode::setCurrentTime() { QTime time = QTime::currentTime(); QString sTime = time.toString("hh:mm:ss"); ui->tempTimeNoHeatMode->append(sTime); } ...

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

mysql,qt,ubuntu,mariadb

It was a problem with the database and not the Qt application, the connection refused if a password was used.

Customizing QDateEdit style

c++,qt

It comes close to the image you've posted: QDateEdit { background-color: white; border-style: solid; border-width: 4px; border-color: rgb(100,100,100); spacing: 5px; } QDateEdit::drop-down { image: url(:/new/myapp/cbarrowdn.png); width:50px; height:15px; subcontrol-position: right top; subcontrol-origin:margin; background-color: white; border-style: solid; border-width: 4px; border-color: rgb(100,100,100); spacing: 5px; } Maybe the key-word here is "sub-control". The arrows...

std::ostream to QString?

c++,qt,exception

You can use an std::stringstream as follows: std::stringstream out; // ^^^^^^ out << "Error in void Cat::eat(const Bird &bird): bird " << bird << " has negative weight" << std::endl; throw(QString::fromStdString(out.str())); // ^^^^^^^^^^^^^^^^^^^^^^^^^^ Specifically, the std::stringstream::str member function will get you an std::string, which you can then pass to the...

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

c++,multithreading,qt

Does the thread affinity has any impact on the class data? No, a QObject's thread affinity only controls which thread it's slot and event handlers run in. Does the class data becomes a thread data? Class data means class static data members - that can't possibly be affected by...

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

qt,python-3.x,qt-creator,pyqt5

When you call a method as object.method(argument1, ...) then object is implicitly passed to the method as the first argument. So with your current code, the line self.setupUi(self,QMainWindow) is actually passing three arguments to the method setupUi. They are self, self (again) and QMainWindow. You might want to read this:...

Context switches between functions and slots in a single thread?

multithreading,qt,qt5

I think that you're confused by the cooperative multitasking exhibited by typical event driven applications, with their run-to-completion event handlers. This is how WIN16, GEM and other such platforms appeared to multitask with no context switches at all. I'll attempt to clear this confusion after exposing the necessary background to...