Qt Two shortcuts for a QAbstractButton

I need to assign two shortcuts to a QAbstractButton, but I cannot find a way to do that. It seems the only method is QAbstractButton::setShortcut(const QKeySequence & key). Is it possible ?

Any readings/books recommended for a beginner mobile Qt developers?

I'm quite new to this mobile development. I just download the Qt SDK from the Nokia web site. My background is C,C++ and I am not very familiar with the visual/IDE kind of stuff. Normally I do things using the console and the vi editor, etc. I have been spending almost 10 years of development mainly on web applications (PHP/Python/Flex/ActionScript/JavaScript/C/etc). I am interested in jumping into this new wagon, of applications for mobiles. I need some guide to start with, any references su

how to embed qtwebkit in non-qt windows application?

I want to embed qtwebkit in my pure c windows GUI application. Are there any examples, sample code on how to do this or is it just not possible? I know its very easy to do inside a QT application but I want to keep my development in C (which can be compiled with a free c compiler). (searched google for several days without any luck).

Qt How to anchor QGraphicsView to a special point on a scene?

How to anchor QGraphicsView to a special point on a scene? I want a center of a view is anchored to the scene point (0,0). But as said in docummentation: If the whole scene is visible in the view, (i.e., there are no visible scroll bars,) the view's alignment will decide where the scene will be rendered in the view. And if I set agnment to Qt::AlignCenter view becomes anchored to the scene center. Is it possibe to do? I need something like QGraphicsView::centerOn that always pu

Building QT Embedded with librt

I'm building QT embedded 4.7 for the OMAP3 platform. at the link stage, it fails because clock_gettime has no symbol. In my own applications in the past, i've solved this by linking in librt. Have i configured QT embedded wrong? how do i get librt to compile in without modifying the make scripts? Thanks a lot

Qt Printing messages from class to ui labels

So I am using the scribble area example from one of the built in examples in QtCreator. There's this particular method, void ScribbleArea::mouseMoveEvent(QMouseEvent *event) { if ((event->buttons() & Qt::LeftButton) && scribbling){ drawLineTo(event->pos()); qDebug()<<printPos(event->pos()); } } In which I edited it a bit to print out the x,y coordinates in the console, which works perfectly. QString ScribbleArea::printPos(QPoint p) { Q

Creating Qt-based gui for a libevent app

I currently use libevent heavily for C/C++ network programming and I love how easily I can make an event-based app without having to worry if I need to use select,poll,epoll,kqueues etc. The apps I've made are text-only, and now I'm looking at Qt/QML to make a GUI for my existing network apps. I just don't know how I can integrate them into one application, as both libevent and qt want to run their own event loops. Do I need to look at running each in its own thread (gui in one thread and libev

OpenCV + OpenGL + Qt

I'm designing my own augmented reality application. I have already detected the 4 corners for the patterns I'm working with. After detecting the 4 corners in a proper order I'm passing them into cvFindExtrinsicCameraParams2. I'm getting nice results for the rotation and translation of the object respect to the camera frame. Now I have to put that information (Rotation Vector and Translation Vector) into OpenGL to draw something. Naturally, I'm using cvRodrigues2 to get the rotation matrix from r

Qt I lose “unicodeness” when qDebug()ing after instancing a QApplication

I am losing the capability of printing unicode characters right after instancing a QApplication object. From the following code and having included all the needed libraries: int main(int argc, char** argv) { qDebug() << "aeiou áéíóú"; QApplication app(argc, argv); qDebug() << "aeiou áéíóú"; return 0; } I am getting this output: aeiou áéíóú aeiou áéíóú How do I fix this odd behaviour? I need to be able to print unicode strings (coming in UTF-8).

Qt QWidget and QML Property Bindings

How can I use property bindings in conjunction with "classic" Qt widgets? Seems to be a cool feature, more powerful than Cocoa Bindings but unfortunately it appears to be restricted to QML. I did not found any documentation about how to set up these bindings in QtDesigner or programmatically using C++/Python.

Qt QDir mkdir with absolutepath

I have problem with the creation of dir with Qt. I would like to create a dir in documents'dir so, I make some things like that : QString path("C:/Users/Me/Documents/MyApp/profiles/"); Qdir dir = QDir::root(); dir.mkdir(path); But that doesn't work! I have test with "/" and "\" for the separators but in the two cases that not work. How I can create my dir? Thank you.

Qt QEventLoop: Cannot be used without QApplication

I'm trying to validate an xml file against a specific schema. So I'm loading the schema into the QXmlSchema object. But I get some strange errors. My code looks like: int main() { QUrl url("http://www.schema-example.org/myschema.xsd"); QXmlSchema schema; if (schema.load(url) == true) qDebug() << "schema is valid"; else qDebug() << "schema is invalid"; return 1; } When I try to run the above piece of code, Qt errors out saying: QEventLoop: Cannot be used without QAppl

Qt: QMenu with translucent background

I use Windows and I want to set a style sheet to a QMenu to give it a translucent background. In order for that to work, I first set the FramelessWindowHint, then I set the WA_TranslucentBackground attribute. Then I set my style sheet and display the menu with the popup method. It is drawn correctly, but it behaves strangely: As soon as it has the FramelessWindowHint, it is always visible (even before calling the popup() method). It does not hide itself anymore after one of its entries has been

Qt change QCompleter result in QLineEdit

The QLineEdit is for entering post code. User may also input city name, while QCompleter will display a list of names for user to select. The problem is, on selecting the name in completer, how could the post code be put in the QLineEdit? I tried to connect QCompleter::activated(QModelIndex) to slot that change the QLineEdit text to post code. But later the text was again set to city name by QLineEdit.

Converting Qt 4.8 to 5 QPluginLoader->instance returns null

I’ve written an Application by using QT 4.8.2. It does dynamically load different plugins to provide multiple functions for the user. Now Qt5 was released and I wanted to convert my project to the newest version. I got everything to work, except loading the plugin with QPluginLoader->instance(). While using Qt 4.8.2 it worked fine. ->errorString says: “The file ‘…/plugins/nlprod.dll’ is not a valid Qt plugin.” That’s my code: PluginLoader.cpp: //"fileName" contains the name of the .dll plug

Qt What is the expected encoding for QWebView::setHtml?

I found a strange effect that I do not understand: I have a HTML file encoded in UTF-8. It also has a meta element with content="text/html; charset=UTF-8"/>. If I load the HTML file in QWebView, it is displayed correctly. If I load the HTML file in a QByteArray (still looks like valid UTF-8), convert it into a QString (still looks like valid UTF-8), and set this via setHTML on the QWebView, it is displayed incorrectly (as if interpreted as ASCII). If I take the same QByteArray, and set it

Escape Spaces in QT

I want to use the QString.split(' ') method to split a input command into the command QStringList commandList = command.split(' '); however command has a UNIX path at the end of it. i.e. it looks something like QString command = new QString("caommand -a -b /path/to\ specific/file"); the path command is specified by the user at runtime(the user escapes any spaces in the path). For some reason command.split(' '); does not escape the spaces. I am new to QT, how does it escape space

Qt project file and system environment variable

I work on Mac Os X with Qt Creator and I want to use a system environment variable as a path in my .pro file. The variable is set in the Project => Build Environment and here's a part of my pro file : DEPENDPATH += . \ $$VLC_QT_PATH INCLUDEPATH += . \ $$VLC_QT_PATH and some output from the terminal : Mac:~ me$ echo $VLC_QT_PATH /Users/me/vlc/include Mac:~ me$ cd $VLC_QT_PATH Mac:~ me$ find . -iname "vlc.h" ./vlc/vlc.h But the include #include "vlc/vlc.h" isn't working

Qt How can QWindow replace QGLWidget?

QT docs say that since qt5 you should use the QOpenGL* classes instead of QGL*. Problem is there is no QGLWidget replacement. I figured out that instead you should use QWindow in conjunction with QOpenGLContext and a call to setSurfaceType( OpenGLSurface );. Only problem is that a QWindow can't have QWidget as parent. So how can I embed a QWindow aka. my OpenGL drawing surface into other widgets?

Qt How to convert .dat file to .dll file

I am using Qt 5.1 to create an application. Unfortunately there is a dependency of a dll file (icudt51.dll) with size over 20 MB, and it is not required in my app too. The solution to this problem is to use a reduced sized icudt file. The following website generates a reduced version of the file but the file is in dat format. How can I get the dll file.

Qt embedded PID of focused window

I use Qt Embedded, which directly draws to framebuffer. Is there a way to get pid of focused window? I tried to use QWSServer, but I didn't find all API for this. Thank You!

Qt How to set QFileDialog's parent to a QQuickView

The only window in my application is a QQuickView which is a subclass of QWindow, not of QWidget, so if I want to use a QFileDialog to give the user the option to save a file, I do not know how to set its parent to be the QQuickView. I know that the QFileDialog works without a parent, but if it does not have a parent, it is not centered over the QQuickView. This is not a big problem on its own, but on my OS (Ubuntu 13.10) a QFileDialog without a parent sometimes appears under the QQuickView wind

Qt Access private static objects in public static method

I'm trying to make a global settings provider for an application. It seemed bulky to have one object duplicated in so many different classes. I've seeth this method work when the private static variable was something simple, like an integer, but I want it to work for QSettings—an object. // settings.h class Settings { public: static void Initialize(); static int serverRefreshRate(); private: QSettings *settings; }; // settings.cpp #include "Server/settings.h" void Settings::Init

Qt - open dialog when action triggered multiple times

I want a notice dialog to come up when an action has been triggered multiple times consecutively (so basically a bit like how StickyKeys is enabled). I understand that I can basically do connect(this->trigger, SIGNAL(triggered()), this, SLOT(onTrigger())) for detecting a single trigger, but how could I detect when it happens 10 times? Thanks. P.S - how could I do a "don't show this message again" QCheckBox?

QT email client using IMAP4

I am developing a QT program that will check for new mails from gmail and download them using IMAP4 protocol. I am unable to write a command to display the messages in my inbox. please help me. Here is a sample of my code. socket->connectToHostEncrypted("imap.gmail.com", 993); if(!socket->waitForConnected(50000)){ qDebug()<<"Error:"<<socket->errorString(); } } void MySocket::connected(){ qDebug()<<"**********\nconnected....\n*********";

Qt Creator won't build

I have been tasked with converting a project that was built in QtCreator to .NET The first thing I am trying to do is build the project in QtCreator so that I can step thru its execution to follow the flow and see some of the variables at play (real values). When I build, I get a lot of errors like this: error: C1083: Cannot open include file: 'QFrame': No such file or directory error: C1083: Cannot open include file: 'QMainWindow': No such file or directory error: C1083: Cannot open include

Compile error in Qt/C++

I am trying to compile an example from a library. I have Qt installed but I think I have to link it and I don't know how. This is the error: g++ face_recognition.cpp -o test In file included from face_recognition.cpp:29:0: /usr/local/include/openbr/openbr_plugin.h:22:23: fatal error: QDataStream: No such file or directory #include <QDataStream> ^ compilation terminated.

QTextStream atEnd() is returning true when starting to read from a file

I want to read and parse contents of the /proc/PID/status file on a linux machine, but the QTextStream.atEnd is always returning true when starting to read. The code: QString procDirectory = "/proc/"; procDirectory.append(QString::number(PID)); procDirectory.append("/status"); QFile inputFile(procDirectory); if (inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); QString line; while (!in.atEnd()) { line = in.rea

How can I set word wrapping in QToolButton's text?

I want to show some text in a QToolButton derived class but it needs to be word wrapped. I would like to do it in an "automatic" way (instead of using \n when needed) just as one can do it when using QLabel and setting word wrapp to true, but I couldn't find anything on Qt Assistant that would do that for me. So, is it possible? And how is it done? If there is nothing like word wrapping for QToolButton, how could I get around this without using "hard code layout" (that is, \n)?

How to disable right click in a QTreeWidget in PyQt?

I have a QTreeWidget where I want to disable right click on the item. Currently I am using itemClicked signal to detect clicks on children of the treeWidget, but I only want to do something when the user left clicks an item and do nothing on right click. Both left and right clicks are getting detected right now and I am not able to differentiate between the two. Thanks in advance!

Qt How can I know when my QItemDelegate is the last item in the list?

My custom item delegate overrides this function: void TileToolDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Everything works fine and draws fine except, for some reason, 'option.viewItemPosition' is always QStyleOptionViewItem::ViewItemPosition::Invalid I'm trying to check if the item is the last item in the list: //Draw the dropshadow, if this is the final item in the list. if(option.viewItemPosition == QStyleOptionViewItem::

how to display part of text in qcombobox (QT)

My understanding is the current display text is related to the qcombobox itemlist content.If one item length is very long and wider than qcombobox's width.how to just display part of the text on the qcombobox? seen from the above picture, QT already displays part of the text(the full item is ending with 'ker', the display item is ending with 'sdl') but can I control the exact display text? because my combobox has a background image and the arrow will be more left than the that in the above pi

Qt multicast works from Windows to Mac but not another around

I use an experimental project to test Qt multicast. It's acting like a simple chat program within a local network. I'm able to send messages from Windows to Mac, but not from Mac to Windows. Please see the comment in Multicast.cpp. Both of them join a predefined group. I used some hard coded IP to find the corresponding interface to bind to. I have also checked the multicast groups on both platforms using netstat and netsh and it show the predefined group on both sides. It's not a firewall iss

Qt Pass keyboard shortcut to QProcess

I'm running vlc in a QProcess to start a video capture stream. However, when I do m_process.terminate(); it does not terminate the vlc process, and doing m_process.kill(); crashes the program and does not save the video file properly. I see QProcess has a write() function, so I was thinking I could send the hotkey Ctrl+Q to the QProcess, but I can't seem to find a way to make it work. Any ideas?

Qt QObject::connect: Cannot queue arguments of type 'QModbusDevice::State'

I'm developing a multithreaded application, I need to instantiate n devices by modbus. So I created a controller (ServiceSM) that instantiates N threads (ServiceSlots). The devices are varied so I had to create "drivers" for each type of device, one of the drivers uses the QModbusClient class, so I created a controller to manage the device type. schema To test the operation of the state machine and connection to the device, I made an example code to run in a graphical interface. I deleted so

Qt QFile path changing from build version to deploy version

I have a program that saves data inside it's own folder. This is how I save the data: QString path = "./config/Values/"+Name+"/"; QDir *myDir = new QDir(); myDir->mkpath(path); path += Name+"_"; path += Date+".txt"; QFile File(path); QTextStream Out(&File); Out.setCodec("UTF-8"); if(!File.open(QFile::WriteOnly | QFile::Text)) return; out << data; File.close(); Every time I run the program through QT, the saved data goes to the path: C:\Andre\Qt files\build-Pesquisa-Desktop_Qt_

Setting QTDIR based on generator in use

I am trying to setup a CMake project which consists of multiple static libraries and one main executable which has dependencies on QT. I would like to be able to select either a MinGW or a MSVC build when I run the cmake build. I recently learned that the QT specific parts of CMake will find the installed library binaries for QT automatically if QTDIR is set as an environment variable and if QTDIR/bin is in the PATH. Now I am wondering how I can set this information dynamically depending on th

Implementing a QtDesigner-like behavior with QtDesigner

I want to implement an editing procedure like the one seen in QtDesigner. That is, having a toolbox of available "blocks" and being able to drag them into the working area of program to create a new instance of some sort of editable object (or widget). I know that I can write it from scratch, but it seems logical that you can create something like QtDesigner within QtDesigner. I noticed that for toolbox they used a combination of Dock Widget and List Widget. But I struggle to come up with the

Qt Custom cell widget in QListView

We have a custom widget that we want to use as item(cell) widget in QListView. And we don't want to use QListWidget. So is there any way to use our custom widget for a cell in QListView. The delegate seems to have a paint() method , but there is no method from which we can return the custom widget that we want to use for a cell. Can any one please help regarding this? Thanks in advance.

Qt ReferenceError: down is not defined in SpinBox QML

I am referring to https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-spinbox and copy pasted the same code, But i am getting following errors: ReferenceError: down is not defined and ReferenceError: up is not defined. Code: import QtQuick 2.6 import QtQuick.Controls 2.1 SpinBox { id: control value: 50 editable: true contentItem: TextInput { z: 2 text: control.textFromValue(control.value, cont

Qt Reliable detection of QProcess finishing

I have a Windows Qt application that uses QProcess to run an external program which may or may not need input. The input will always be y followed by ENTER if needed. And, if y is entered, the program exits immediately. So the actions I take in the code are: QProcess process; QString cmd = QString("myprog.exe %1").arg(myParam); process.start(cmd); if (! process.waitForStarted(10000)) { logError("Timed out starting preparation!"); return; } process.write("y\n&quo

Qt QML QQuickText: Cannot anchor to an item that isn't a parent or sibling

When I use TumblerColumn in my Tumbler, I get QML QQuickText: Cannot anchor to an item that isn't a parent or sibling, When I use Tumbler alone the error doesn't appear. I can't figure out what is the problem with TumblerColumn. Here is my Dialog code import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Extras 1.2 Dialog { id: customTimerInputDialog title: "Custom timer" height: 150 width: 300 standardButtons: StandardButton.Ok | Standar

Qt QMap<int, MyClass> ignores insert command

I've a question that couldn't find anywhere. I have a QMap that's ignoring the QMap.insert(Key, Value) command. Here's the code: //gets the selected problem index on the ProblemList int selProblem = ui->tree_projects->currentItem()->data(0, Qt::UserRole).toInt(); //creates a new problem, sets its values and then replaces the old one on the ProblemsList variable ProblemSets nProblem; if(!problemsList.isEmpty()) //problemsList is an attribute of MainWindow nP

Qt How to use the opengl in the QGraphicsView, and then compile to wasm?

I create a Qt project, in this project, I use the QGraphicsView to show a circle. i try to use opengl to show it, this function is, and it is successful in the PC program, but when I compile to the wasm with emscripten, it is failed to show the graphics in the web. I do not know why? here is the method to use opengl to render the graphic. setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));

Error building QMYSQL Plugin for Qt on Windows

I recently re-installed Qt - and now I am having issues with my MySQL drivers for Qt. I now get the error: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 So I am trying to build the QMYSQL Driver. So far I have... Downloaded the MySQL Community installer by running mysql-installer-web-community- And installed the x86 version of the MySQL Connector C 6.11, which saved to C:\Program Files (x86)\MySQL\MySQL Connector C

Qt Can a QProcess started when QLineEdit is in focus be terminated when the QLineEdit is out of focus?

I am creating an app using QtCreator 4.12 and am using a touch screen for input. I want a virtual keyboard to pop up when any QLineEdit is in focus and the keyboard to disappear when the QLineEdit is out of focus. I am using matchbox for the virtual keyboard and am running: keyboard->start("/bin/sh",QStringList()<<"keyboard.sh"); where the keyboard.sh file runs the matchbox-keyboard command to get the keyboard on screen. The keyboard does pop up on screen when QLine

Qt Creator: how to create Qt6 project?

I have installed Qt 6.0.3 and 6.1.0. And I want to create Qt 6 Quick project. I start Qt Creator, click "New", "Qt Quick Application - Empty", "Choose...". Then I type the name of my project and click "Next". On the "Build System" step I select any build system(qmake, CMake or QBS, it does not affect the next step) and click "Next". On the next step "Details" there is a drop-down with a list of available Qt versions. But it d

  1    2   3   4   5   6  ... 下一页 最后一页 共 108 页