Menu
  • HOME
  • TAGS

How to make a QSlider read-only?

qt,qt5,qslider

AFAIK such feature is not available in the QSlider implementation. However, you can create your own class deriving from QSlider and implement the desired behavior by overwriting mousePressEvent, mouseReleaseEvent, mouseMoveEvent, keyPressEvent and keyReleaseEvent and only call the respective parent implementation if the readOnly property is set to false. Luckily, such...

QOpenGLWidget overriding projection matrix

qt,opengl,qt5

However, somewhere this is getting overridden. When I print the projection matrix in the paintGL() function, it shows it as identity. And you're surprised exactly why? Qt5 may use OpenGL for drawing its stuff. Which means that Qt will have to set the state of the OpenGL context according...

Increase font size in Qt

qt,fonts,qt5

This question and answer How do you get the system default font size in Qt? suggests that a QFont object starts with the system default. Also, the API docs indicate that the default QFont constructor does this (http://doc.qt.io/qt-5/qfont.html#QFont), and also suggests QGuiApplication::font() as another way to get the default font....

QScintilla Font Combo Box Confliction

qt,qt4,qt5,qt5.4,qscintilla

I changed my code to this. void SquareIDE::on_fontBox_currentFontChanged(const QFont &f) { ui->fontBox->setFont(f); ui->textEdit->setMarginsFont(f); lexer1->setFont(f); } ...

QT5: how to create .app bundle for macx

deployment,bundle,qt5,.app

If your application uses libraries other than Qt, you need to copy the frameworks in yourApplication.app/Contents/Frameworks/ Edit: If your program is a console application, just create a shell script like this, put it in the same directory as your executable in app bundle, and modify your Info.plist so that this...

Qt5, how to display stretched font (i.e. double width or double heigh)?

qt,fonts,qt5,stretch

The question conflates two issues: How to draw stretched fonts? It's easy: change the horizontal or vertical scaling of the QPainter. Qt will do the rest for you. E.g: QPainter p; p.setTransform(QTransform(2.0, 0, 0, 1.0, 0, 0))); p.drawText(0, 0, "STRETCHED"); How to express stretch in rich text? That's not directly...

How to make intermediate object file not a library using qmake?

qt5,static-linking,qmake

I solved this problem with "static library config" so that it will not make ".so" libs and then link that static library with main program. TEMPLATE = lib CONFIG += staticlib ...

catch mouseMoveEvent on Qt5's QQuickItem

c++,qt,qml,qt5

Thanks to Jeremy Friesner's comment I get the working code: main.cpp: #include <QApplication> #include <QQmlApplicationEngine> #include <QtQuick> class MyItem : public QQuickItem { public: MyItem() { setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::AllButtons); setFlag(ItemAcceptsInputMethod, true); } void mousePressEvent(QMouseEvent* event) { QQuickItem::mousePressEvent(event); qDebug() << event->pos(); } //This is function to override: void hoverMoveEvent(QHoverEvent* event) {...

Undesired auto scrolling of QComboBoxes

c++,qt,qt5

It is a bug in the version of Qt 5.4.1. Reported.

How to obtain entire Qt StyleSheet for QMacStyle

qt,qt5,qstylesheet

QMacStyle is a QStyle subclass that is using Apple's HITheme for drawing (look for the files qmacstyle_mac* to see the implementation), so there is no stylesheet to obtain.

Qt X11BypassWindowManagerHint open QFileDialog crash

qt,qt5,x11,cinnamon

Finally I found the answer to this. I must thank @sashoalm for leading me through the debugging process but I guess it is not exactly a bug of cinnamon. In the open file call: QFileDialog::getOpenFileName(this, tr("Open SRT File"), "/home", tr("SRT Files (*.srt)")); the problem is solved when I change this...

How to setText for QPlainTextEdit?

qt,qt5,settext

It's very simple, just get the current document and set its text: plain_text_edit->document()->setPlainText(text); Alternative way, first clear the editor, then append new text: plain_text_edit->clear(); // unless you know the editor is empty plain_text_edit->appendPlainText(text); You could also use text cursor of the editor in many ways to achieve this, most simply...

QStackedLayout implicitly shows added widget

c++,qt,qt5

Is this supposed to work that way? I suspect that the author of the QStackedLayout class never considered the possibility of somebody putting a top-level-widget into the layout. That seems like an odd thing to want to do. Regarding intent: without talking to the author, though, the best we...

Qt5: function.toString() not working

javascript,qt,qml,qt5

toString as applied to a function is an implementation detail. Per ECMA-262, it should works as you expect, but evidently, as implemented, it doesn't :( In any case, the standard allows it to work differently between implementations. You depended on an implementation detail, then changed your implementations, so you shouldn't...

Qt event for delegate in table

qt,qt5,qtableview,qitemdelegate

Mouse events are send to the QAbstractItemDelegate::editorEvent() method, even if they don't start editing of the item. See: http://doc.qt.io/qt-5/qabstractitemdelegate.html#editorEvent...

Encoding a QString in JSON

qt,qt5,qwebelement

It's really not that difficult. Start by building up the structure with QJsonObjects QJsonObject obj; obj.insert("tag1", QString("Some text")); Then use QDocument to get a string in Json format QJsonDocument doc(obj); QByteArray data = doc.toJson(QJsonDocument::Compact); QString jsonString(data); This will produce a string, in the form of: - { "tag1" : "Some...

Linux Netcat works as Expected but not QTCPSocket on Raspberry Pi

linux,qt,tcp,qt5,qtcpsocket

Here is how you do it: #include "tcpreceiver.h" // Debug #include <QDebug> #include <QHostAddress> TcpReceiver::TcpReceiver(QObject *parent) : QObject(parent) { // Create a server qDebug() << "Creating a TCP Server..."; // Create the server m_Server = new QTcpServer(this); // Listen on the proper port m_Server->listen( QHostAddress::Any, 0x2616 ); // Hook up...

Qt5.4 QAudioOutput on Raspberry Pi With PulseAudio on the 3.5mm Audio Jack Doesn't work but Qt 5.3 Does

qt,raspberry-pi,qt5,alsa,pulseaudio

The answer was to run in session mode ( not a system-wide PulseAudio daemon ) and edit default.pa to look like this: ## Create the default output device #load-module module-udev-detect tsched=0 load-module module-alsa-card device_id=0 #load-module module-alsa-card device_id=0 tsched=0 fragments=10 fragment_size=640 tsched_buffer_size=4194384 tsched_buffer_watermark=262144 #load-module module-alsa-card device_id=0 tsched=0 fragments=6 fragment_size=16 tsched_buffer_size=4194384 tsched_buffer_watermark=262144...

How to compile Qt 5 projects without QtCreator?

c++,eclipse,cmake,qt5,kdevelop

Check out the documentation for cmake-qt at http://www.cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html According to that target_link_libraries(qt4_training Qt5::Widgets) might fix your linker errors. Your include directories also look wrong, you should not add LIBRARIES variables here...

Qt convert ISO date to QDate

c++,qt,qt5

Here is your answer: QString str = "2015-05-17T05:16:22.126Z"; QDateTime dateTime = QDateTime::fromString(str, "yyyy-MM-ddThh:mm:ss.zzzZ"); QString newStr = dateTime.toString("yyyy-mm-dd"); (don't hesitate to see the documentation of the Qt framework, this page for example)...

Limit QKeySequence/QKeySequenceEdit to only one shortcut

c++,qt,qt5,qkeyevent,qkeysequence

Solved it, not the best solution but quick...If you want something more customize, I think you have to build it yourself... customkeysequenceedit.h: #ifndef CUSTOMKEYSEQUENCEEDIT_H #define CUSTOMKEYSEQUENCEEDIT_H #include <QKeySequenceEdit> class QKeyEvent; class CustomKeySequenceEdit : public QKeySequenceEdit { Q_OBJECT public: explicit CustomKeySequenceEdit(QWidget *parent = 0); ~CustomKeySequenceEdit(); protected: void keyPressEvent(QKeyEvent *pEvent); }; #endif...

QApplication dont exit after i close all QWidget

c++,qt5

You create two event loops: w.exec() a.exec() The second event loop is started after you close the dialog, so it will wait indefinitely for a window to be closed. You can either call show() for the dialog or not use the QApplication event loop at all: int main(int argc, char...

setting wrapMode property of Text in ScrollView

qt,qml,qt5,qtquick2

Just remove ColumnLayout, that's not necessary here. This works for me (if that's what you're looking for): import QtQuick 2.2 import QtQuick.Controls 1.3 ApplicationWindow { id: appWindow visible: true width: 300 height: 500 ScrollView { anchors.fill: parent Column { Repeater { model: 10 delegate: Text { width: appWindow.width - 50...

Why Qt QML doesn't properly bind properties?

c++,qt,qml,qt5,qtquick2

I found the issue! Very unobvious (haven't found documented anywhere) and it fails silently. The problem is that MyCustomItem contained a property with the same name of outer booleal property isExpanded so in this code: MyCustomItem { id: myId visible: isExpanded // other stuff } isExpanded is from MyCustomItem. But...

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,...

CSS to access QHeaderView item columns to set bacround-image, or set large icon to QHeaderView

css,qt,qt5,qheaderview

All i wanted was to set large icons to QHeaderView but with css i can access just to first and last item, i found a solution to change size of QHeaderView items icons via QProxyStyle class and i will share my solution here: All you need to to is to...

How to display QVector3D in one cell in QTableView via qAbstractTableModel's subclass

c++,qt,qt5,qtableview,qvector3d

The Qt::DisplayRole requires a QString in the variant, but you are providing a QVector3D. There is no conversion from QVector3D to QString in QVariant (see documentation). You should either convert the Vector to a string representation yourself, or use a QStyledItemDelegate to override the displayText method for converting QVector3D to...

linux gst_element_factory_make (“rtspsrc”, NULL) fails on qt5

linux,qt5,gstreamer,rtsp

After several hours digging my head, I finally found the answer. it was not about rtspsrc. in fact, I had to use gstreamer-0.10, and I tried to create avdec_h264 element with that version, instead of gstreamer-1.0. But I finally move to ffdec_h264, wich is an element of gstreamer-0.10, and ......

How to open/close file at a specific entry in Qt5

c++,io,qt5

You can read your file line by line like this. Create your variable indicating whether to read e.g. readEnabled. After you've read the line, check for your tokens: QFile inputFile(fileName); QString outputText, startToken = "#qtread", endToken = "#qtend"; if (inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); bool readEnabled = false; while (!in.atEnd()) {...

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 - Draw on canvas

qt,drawing,qt5

I have provided an example that shows this. https://github.com/jsuppe/qt-paint What this example shows is: Create a widget & handle mouse events & paint event The widget contains a QImage which is the size of the widget. Write to the QImage the pixel coordinates when the mouse events occur Tell the...

Qt.inputMethod.show () doesn't show any keyboard

qt,qml,qt5,qtquick2

As stated in the comments, the Qt Virtual Keyboard is only available in top level licensed version of Qt, i.e. the "professional" and "enterprise" ones, as clearly demonstrated by the feature table available at this download page. "Community edition" (the open source version of Qt) does not include the keyboard....

QMutex in slots

c++,qt,qt5,mutex

Get rid of QApplication::processEvents and move the long operation that freezes your GUI to a new thread. You can use for example a worker object that you move to a new thread. There is a good example of this in the docs. You should also read this to learn more...

Single quotes prevent bindValue from replacing placeholder mark

c++,qt,sqlite,qt5,qtsql

It is not a bug. Just don't use the single quotes. The bindValue mechanism does not just replace your :path with a string in your statement. No risk of name conflicts. See it as some kind of different namespace. :-) http://en.wikipedia.org/wiki/Prepared_statement: Prepared statements are normally executed through a non-SQL binary...

How can I get the used configure commandline options for the installed Qt5

qt5,configure

No, there is not. You could fake it, if you still have the source tree. In qt5/qtbase you find two files: config.summary and config.status. Those contain the info you seek. However, these files are not part of a normal installation.

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...

Windows C++ GUI application

c++,windows,visual-studio,cmake,qt5

Edit CMakeLists.txt for create WIN32 application IF(MSVC) SET(OPTIONS WIN32) ENDIF(MSVC) ADD_EXECUTABLE(${APP_NAME} ${OPTIONS} ${HEADER_FILES} ${SOURCE_FILES} } Edit main.cpp for using wWinMain and convert input args to argc, argv #ifdef _MSC_VER # include <windows.h> # include <shellapi.h> #endif /// ... some code #ifdef _MSC_VER INT WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPWSTR, INT)...

How to run custom commands during `make uninstall` from qmake in QT5?

c++,qt,makefile,qt5,qmake

try to use .uninstall command. mytarget2.path = ~/Documents/inst mytarget2.target = test.txt mytarget2.commands = @echo "custom command" mytarget2.uninstall = @echo "uninstall" INSTALLS += mytarget2 it will generate this makefile: ####### Install install_mytarget2: first FORCE @test -d $(INSTALL_ROOT)/Users/mac/Documents/inst || mkdir -p $(INSTALL_ROOT)/Users/mac/Documents/inst @echo custom command uninstall_mytarget2: FORCE @echo uninstall -$(DEL_DIR) $(INSTALL_ROOT)/Users/mac/Documents/inst/ install:...

QWebView or QWebEngineView

qt,qt5,qtwebkit,qt5.4,qtwebengine

I would give QtWebEngine a try. It is replacing QtWebKit for a reason. If you control the HTML that is getting rendered, then it probably doesn't hurt to use QWebKit. Just make sure you test your pages beforehand. QWebView uses WebKit as the backend. http://doc.qt.io/qt-5/qwebview.html#details QWebEngineView uses Chromium as the...

Force Qt5 to load SSL dlls from exe dir

c++,windows,qt,dll,qt5

QSystemLibrary::load is called with onlySystemDirectory = false for SSL, so QFileInfo(qAppFileName()).path() is the first place where the DLLs are searched. Search order: application dir system path (e.g. C:\Windows\System32) all paths in PATH I don't find documentation for that, but in our software, Qt finds SSL libeay32.dll and ssleay32.dll when they...

Git Clone QT5 Gitorious

git,qt5,gitorious

Seems like there is a Qt 5 project on Github: https://github.com/qtproject/qt5 git clone https://github.com/qtproject/qt5.git --branch v5.3.1 --single-branch 5_3_1_x64_msvc2012 If you're unsure about the integrity of the code, you can compare the tree SHA-1 of your new clone with a reference one that you have already cloned some time ago (since...

Endian safe conversion of two chars to unsigned short

c++,qt,qt5

You can use the <QtEndian> functions. In your case, you could use qFromLittleEndian. It is a template function, so you don't need to pass chars into a function, just a quint16 and it will return a host-endian version of that quint16. When responding, you could just call qToLittleEndian.

python 3 how to put pics inside my program

image,python-3.x,qt5,py2exe

Qt is using a resource system for this task. This is also supported by pyqt. There are a few answers here on SO already: here and here Here is a quick example: First, create a resource file (e.g., resources.qrc). <!DOCTYPE RCC><RCC version="1.0"> <qresource prefix="/images"> <file alias="image.png">images/image.png</file> </qresource> </RCC> Then compile...

WA_DeleteOnClose delete all members?

c++,delete,heap,qt5,destructor

Qt will just call your destructor, it doesn't go and delete every member of your class itself! If you have a delete[] myArray in your class's destructor, your array will be deleted correctly. If you don't delete[] your array in the destructor, it will leak. But better yet, don't bother...

QML (Qt 5): Overlay button on top left corner of resized image

qt,qml,qt5,qtquick2

You need to access the actual size of the scaled image, in order to so there is the paintedHeight property and paintedWidth. This would result in Item { Image { id: img source: "cluster.png" width: 150 height: 150 fillMode: Image.PreserveAspectFit } Button { id: butn anchors.left: img.left anchors.top: img.top anchors.leftMargin:...

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.

QT5 qml receive c++ object in slot

qt,qml,qt5,qtquick2

QML uses data from Qt by converting every parameter to QVariant and then, if possible, to native JavaScript values. If they cannot be converted to JS, you can still copy and pass them with JS but you won't be able to use them. Without extending QVariant, only QObject* can be...

How do I create a qt app in nim

linux,qt5,qtgui,nim,nimrod

You can use qt as the UI for your Linux app and then build the logical backend of your app in Nim, export it as a C library and call it from the user interface layer. That's what I did for Seohtracker, the UI is done in ObjectiveC for OSX...

How in Qt5 to check if url is available?

qt,network-programming,qt5

Yes, you can do a HEAD request to a given URL. bool urlExists (QString url_string) { QUrl url(url_string); QTcpSocket socket; socket.connectToHost(url.host(), 80); if (socket.waitForConnected()) { socket.write("HEAD " + url.path().toUtf8() + " HTTP/1.1\r\n" "Host: " + url.host().toUtf8() + "\r\n\r\n"); if (socket.waitForReadyRead()) { QByteArray bytes = socket.readAll(); if (bytes.contains("200 OK")) { return...

TableView in QT5 doesn't show MYSQL Data, just empty rows are shown

c++,mysql,qt,tableview,qt5

I think (since we don't have Datenbank source code) the problem is in declaring Datenbank db; on the stack, when the function exist, database is closed leading to invalidating your query and model, to solve the issue, either declare it on the heap using new or use it as a...

qmake's write_file() and system() doesn't want to make a file

qt,qt5,qmake

Huh! I found the solution and it may sounds like buy yourself some brain. I thought, that qmake is launched every time the project file is changed (output of message commands proved my thoughts), but it's not really the way things happen in Qt. I don't know how exactly, but...

Window on top of another window?

c++,qt,qt5,always-on-top

You don't need to set WindowStaysOnTopHint flag to force your dialog stay on top of main window. Just set main window as the parent of the dialog when instantiating it in the constructor of main window like : dialog = new MyDialog(this); ...

Drawing errors and crash with QWidget::createWindowContainer

c++,qt,qt5

First off all - thank you for this question. Before this time I am do not know about this feature in Qt. I spend some time to implement your solution and have the same problem: white border. After few tests I try to do window reparenting on the fly and...

Qt/C++ how to wait a slot when signal emitted

c++,multithreading,qt5,signals-slots

My first thought is that having either thread block until an operation in the other thread completes is a poor design -- it partially defeats the purpose of having multiple threads, which is to allow multiple operations to run in parallel. It's also liable to result in deadlocks if you're...

Where did file downloaded with PyQt5 network access manager go? And how do I save it?

qt,qt5,pyqt5,qnetworkaccessmanager,qnetworkreply

The reply is a QNetworkReply, which is subclass of QIODevice. So, it is roughly equivalent to the file-like objects found in python. Once the file has downloaded, you should be able to do something like: data = self.reply.readAll().data() which will give you a python byte-string that can be saved to...

QDataStream allocation between members

c++,qt,qt5,qdatastream

There is an error in your code. This line: QDataStream read(&file); defines a local variable, which overrides class member. Instead you should do this: read.setDevice(&file); ...

QML ScrollView with ColumnLayout

c++,layout,qml,qt5

I would go with a plain column and access the desired width property directly by id. As I understand these container elements are measuring their size depending on their content, that might be the reason why setting the ColumnLayouts width has no effect. This works for me: ScrollView { anchors.fill:...

How to react to 'Close window' in right-click menu of task bar in Windows

windows,qt,qt5

The behavior you're seeing is not really surprising. In fact, it's exactly what happens with a (mostly) well-behaved Windows app like Notepad, so I'm not sure I'd even call it a bug. Open Notepad, and select Help->About to get a modal dialog. Now choose Close from the task bar icon....

detect when mouse cursor is over an irregular shape picture in Qt5 and QML

qt,qml,qt5

Use QPainterPath to construct the shape of each country. You can do this using moveTo() and lineTo(). Once you have this, make it a member variable of a custom QQuickItem - let's call it CountryItem. You could make the image a child of this item after exposing it to QML...

How do I highlight specific letters in the text of a QListWidgetItem?

c++,css,qt,qt5

Usually you have to create a custom delegate that paints the text the way you want. You can read about it here. But if you want to customize a QListWidget you can simply use the QListWidget::setItemWidget method: QListWidget *list = new QListWidget; QListWidgetItem *item = new QListWidgetItem(list); QLabel *label =...

LibHaru QT5 cannot find usr/local/lib, file format not recognized

qt,qt5,ubuntu-14.04,libharu

INCLUDEPATH +=/usr/local/include LIBS +=-L/usr/local/lib -lhpdf note that I used -lhpdf instead of -libhpdf and ensure that file libhpdf.a exists in the mentioned path. See this answer: How to include needed C library using gcc?...

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. ...

QJSonArray to QString conversion

c++,qt5,qstring

To quote the documentation: You can convert the array to and from text based JSON through QJsonDocument. In other words, all you need to do is this: QJSonArray data; QJSonDocument doc; doc.setArray(data); QString dataToString(doc.toJson()); That's all there is to it!...

Simple Qt app doesn't open on Mac OSX Yosemite

c++,osx,qt,qt5

I guess the file main.qml is not found. You should get an error message "... File not found" in the console. To solve this problem either supply a valid path on your drive or use Qt's resource management. This is documented here, I'll outline the steps: 1) Create file test.qrc...

How do I get the return value of the EXISTS operator with QtSql?

c++,qt,sqlite,qt5

query.prepare("SELECT EXISTS(SELECT 1 FROM files WHERE pid=:pid AND files.name=':name' LIMIT 1);"); query.bindValue(":pid", PID); query.bindValue(":name", fi.fileName()); if (!query.exec()){ qCritical() << query.lastError(); qFatal(SQLERR); } else { if( query.next( ) ) QMessageBox::information( NULL , "Test" , query.value( 0 ).toString( ) ); } That works perfectly for me. Basically .next( ) will retrieve the...

How to prevent tab buttons from shrinking in QTabWidget

qt,tabs,qt5,qtabwidget,qtabbar

You can disable text elision with: tabs->setElideMode(Qt::ElideNone); ...

How to enable/disable WebKit features when compiling as part of Qt5 library

c++,qt,webkit,qt5,qtwebkit

If you compile Qt first without QtWebKit (configure -skip qtwebkit), you can modify Tools/qmake/mkspecs/features/features.pri from the QtWebKit source to enable or disable features. Then generate Makefile from WebKit.pro and run nmake. Now QtWebKit should build with the features you've set.

qt5 fstream doesnt work

qt,qt5,fstream

When you compile your project a folder with the project name and the build rules should appear, which has "Release" and "Debug" as sub folders. Copy the txt into that folder, NOT in the sub folders. The folder name should look similiar to this: myproject-build-desktop-Qt_4_7_4_for_Desktop_-_MSVC2008__Qt_SDK__Debug ...

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....

Strange error while trying to deploy qt5 app on raspberry pi

c++,linux,raspberry-pi,qt5,raspbian

Your default argument for QString isn't valid: QString label = NULL NULL is just a macro for 0, so you are effectively saying QString label = 0. QString doesn't define a way to create a QString from an int, which is the reason for your error - on most platforms...

QRegularExpression find match with captured length backwards

c++,qt,qt5,qregularexpression

Note that in Qt5 QRegExp != QRegularExpression and I'm much more familiar with QRegExp. That said, I can't see a way to do what you want with QRegularExpression or QRegularExpression::match(). I would instead use QString::indexOf to search forwards and QString::lastIndexOf to search backwards. You can do this with either QRegExp...

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

qt,qt5,qt-quick,qtnetwork

No. Prove The following command line script generates a dependency list of Qt 5 modules on Linux: # Run in e.g. Qt/5.4/gcc_64/lib for f in libQt5*.so; do mod=$(basename "$f" .so | cut -c "7-"); echo "$mod"; ldd "$f" | grep "libQt5" | cut -f 1 -d">" | tr -dc "a-zA-Z0-9.[:space:]"...

Is it possible to control multiple VideoWidgets with one MediaPlayer?

qt,qt5,qmediaplayer

One way to show a vídeo in multiple widgets is using a custom Video Surface class, and use them to generate a serie of QImage for you, and process/show those images the way you like. Example of a custom Video Surface: /* Here is our custom video surface, */ class...

How to embed a custom font in my application

c++,qt,qt5

Ahhh... now, after you added your .qrc, I understand. Easy to explain: <file alias="ae_AlMateen">ae_AlMateen.ttf</file> You added an alias in your .qrc file. If you remove alias="ae_AlMateen" it will work as we all expected... with .ttf extension....

why received the following error when using QT5?

c++,qt,qt5

This should fix it for you: https://forum.qt.io/topic/21605/solved-qt5-vs2010-qdatetime-not-enough-actual-parameters-for-macro-min-max/5 The C++ min/max macro are being wrong called. So you can set the NOMINMAX before call the header to solve. There're several ways to achieve that, as it's being described in the link I sent. i.e: #define NOMINMAX #include <windows.h> or set the...

How to override just one property:value pair in Qt StyleSheet

qt,qt5,qpushbutton,qstylesheet

As Illuminated in the parallel post How to obtain entire Qt StyleSheet for QMacStyle, my original question was based on confused premise. In Qt, all widgets are styled via a QStyle(). By default for Qt code on OSX (as in my first block of demonstration code in the original question),...

How to move class in the same thread

c++,qt,qt5,qthread

It is possible to have your DeviceMngr and Framework instances in the same thread. To do this, you'll need to keep the QThread instance you want to have in common between them in one place (or pass a pointer). Do you have a reason for not making your DeviceMngr instance...

libcurl curl_easy_perform() crashes program when moved inside function

c++,qt5,libcurl

file inside DownloadToFile already is a pointer to the ftpfile-structure, so remove the & before the file variable: curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)file); ...

How do I compile Qt5 dev branch from git repository for the Raspberry Pi?

qt,raspberry-pi,cross-platform,qt5,raspbian

To create a Qt5 for the Raspberry Pi several steps are necessary: Get the Qt5 sources from git. To checkout Qt5: git clone http://code.qt.io/cgit/qt/qt5.git or git clone http://code.qt.io/qt/qt5.git The repository might change from time to time. The qt project is still evolving. Above command in done on the Linux host....

How to share build step in Qt Creator

qt,qt-creator,qt5,qmake

Try replacing the custom build steps with QMAKE_POST_LINK commands (QMAKE_POST_LINK Reference) They can be linked to a script that can be committed: win32 { QMAKE_POST_LINK = install/win/deploy } unix { QMAKE_POST_LINK = install/unix/deploy } To create pre-build steps, this is a nice example: Pre-pre-build commands with qmake....

What is the difference between QAndroidJniObject::callMethod() and QAndroidJniObject::callObjectMethod()?

android,c++,qt,qt5,qtandroidextras

The main difference is that QAndroidJniObject::callMethod returns a primitive data type like jint or jbyte but QAndroidJniObject::callObjectMethod returns an object of type QAndroidJniObject. Using which one all depends on your needs and the return type of the function you want to call. If your function returns an object type like...

How to check two QLineEdit If they are not empty

c++,qt,qt5

Just connect a single slot to handle textChanged signals of both LineEdits void Question_Answer::onTextChanged(const QString &arg1){ if(ui->newAnswer_txt->text().isEmpty() || ui->newQuestion_txt->text().isEmpty()){ ui->addNewQuestion_btn->setEnabled(false); }else{ ui->addNewQuestion_btn->setEnabled(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...

How to prevent clipping of cornerWidget in QMenuBar

qt,qt5,qmenubar

OSX menu bars must have a fixed height and your button doesn't fit there. Try to remove layout margins: cornerLayout->setContentsMargins(0, 0, 0, 0); And / or make the button smaller: newWindowButton->setMaximumHeight(30); Also, adjust margin to what best fits your needs: menuCorner->setStyleSheet("margin-top: 2"); This is how it looks for me: ...

QTabWidget does not respect spacing from layout

qt,qt5,qtabwidget

I understand where I went wrong. In the first case I add my scrollarea as a sub-widget to the centralwidget. In the second example I add the scrollarea as the centralwidget which expands it to the whole tabwidget. I resolved the second case by first adding a holder QWidget as...

QToolButton with icon + text: How to center both?

qt,qt5,text-alignment,qstyle,qstylesheet

As I suggest in answer to you another question. http://stackoverflow.com/a/28630318/1917249 Do not use QToolButton, just use QPushButton, and add popup menu if needed. Then you wont have different sizes of QToolButton and QPushButton widgets. And you will have centered icon and text. Popupmenu can be easily added to QPushButton (...

QToolButton with text: Overwrite minimal height to minic regular button height

qt,qt5,qgridlayout,qaction,qsizepolicy

I do not understand what do you want to achieve. Difference between QPushButton and QToolButton is that, QToolButton has implemented PopupMenu ( can be done easily for QPushButton also ) As I understand visual difference is only small arrow in lower right corner of QToolButton, when you use added QActions...

Easy readout from QDataStream to QStringList

c++,qt,c++11,qt5,qt5.4

QStringList has serialization operators implemented, but it will only work for data streams which were serialized from a QStringList to begin with. QStringList l; l << "aaa" << "bbb" << "ccc"; QBuffer buf; QDataStream stream(&buf); buf.open(QIODevice::ReadWrite); stream << l; buf.seek(0); QStringList l1; stream >> l1; qDebug() << l1; // works...

how to suppress namespace prefix with Qt5.4 QXmlStreamWriter

xml,qt,qt5,xml-namespaces,qt5.4

QXmlStreamReader::setNamespaceProcessing() is the answer: reader.setNamespaceProcessing(false); ...

Building vtk with QT5 windows 8

windows,cmake,qt5,vtk

Did you do step 3 and 4 here? : Combining Qt 5.4.1 with vtk 6.2.0 (using CMake GUI 3.2.1) on windows I'm guessing you didn't change VK_QT_VERSION to 5...

QDomDocument toString

xml,dom,qt5

QDomDocument stores the attributes of a given node in a QHash, which protects itself against algoritmic complexity attacks by salting the hash calculation of any given key with a random salt. Of course, for testing purposes this is a counter feature. Solution: run your testcase with the environment variable QT_HASH_SEED...

Rotate QPixmap on a QGraphicsScene around a point

qt,qt5

You should rotate the QGraphicsPixmapItem, not the pixmap itself. Use QGraphicsItem::setTransformOriginPoint to define the transform origin point and QGraphicsItem::setRotation to rotate the item.

how to use QFtp::list and QFtp::listInfo to check if directory exists

c++,qt,ftp,qt5

Function list() work asynchronously. After you call this function it immediately returns unique identifier. This id passed in commandStarted() signal when command started and in commandFinished() signal when list command finished. Between this two signals listInfo() signal is emitted for each directory entry found. So before upload to directory you...

Setting Up OpenGL in Qt for QOpenGLWidget

c++,qt,opengl,qt5

I came up with an interesting solution. Perhaps it was obvious but I didn't see it at first. I basically created a single static variable of type QOpenGLFunctions_3_3_Core inside a dummy class, GL, and used that through out the entire code whenever an OpenGL function was needed. For example class...

C++ Abstract Class error on Constructor in Qt 5

c++,constructor,abstract-class,qt5

The methods you do not implement in the abstract class, should be pure virtual methods. That mean they should be followed by = 0. For example: virtual double value() = 0; This tells the compiler that this is a pure virtual method. For an explanation of the difference between virtual...

Qt4 to Qt5: QPainter::drawPixmapFragments() with 5 arguments - how to solve? (Updated)

c++,qt,qt5,qt4.8,qt5.4

According to http://qt.apidoc.info/5.1.1/qtgui/qpainter-pixmapfragment.html in Qt5 your code should look like this: void ButtonSelector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); //painter->drawPixmap(m_backGnd.rect(), m_backGnd); QRectF rectSrc = QRectF(m_backGnd.rect()); QRectF rectTrg = boundingRect(); QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(rectTrg.center(), rectSrc, rectTrg.width() / rectSrc.width(), rectTrg.height() /...

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

c++,qt,c++11,macros,qt5

You should be able to fix that problem by using: #include "ConflictHeader.h"//Include conflicted header #ifdef _c #undef _c #endif A better option might be to create a wrapper .h file fro ConflictHeader.h and use the wrappr .h file in rest of your code. ConflictHeaderW.h: #pragma once #include "ConflictHeader.h" #ifdef _c...

Overlay while loading page into QWebView

c++,qt,qt5

You can use the LoadingOverlay class provided in this answer to draw an overlay over any QWidget. In your case, show the overlay on top of the QWebView when the signal loadStarted is triggered and hide it, when the signal loadFinished is triggered. The following code should get you started....

Qt5 - How to make qurl detect wether the given url is local or not and add “http://” if not?

qt,qt5,qurl

You can use QUrl:fromUserInput(...) for that purpose. QString first("qt-project.org"); QString second("ftp.qt-project.org"); QString third("hostname"); QString fourth("/home/user/test.html"); qDebug() << QUrl::fromUserInput(first); // QUrl( "http://qt-project.org" ) qDebug() << QUrl::fromUserInput(second); // QUrl( "ftp://ftp.qt-project.org" ) qDebug() << QUrl::fromUserInput(third); // QUrl( "http://hostname" ) qDebug() << QUrl::fromUserInput(fourth); // QUrl( "file:///home/user/test.html" ) ...