qt

Qt QPlainTextEdit background

I want to change the background color of a QPlainTextEdit, how do I do this? ...

Autocompletion with qcompleter for fragments in the middle of a word

Is there an example available of a QCompleter subclass that will provide autocompletions for fragments that appear in the middle of words? eg: Suppose you have the wordlist { "apple", "pear", "banana" }. When the user types 'p', the suggested autocompletions should be apple and pear, but not banana (because apple and pear both contai...

QT MySql connectivity using Windows XP, Qt Creator 4.5.2(windows 32 bit)

Platform: Windows XP, Qt Creator Ide 4.5.2 MySql is setup here as well. I want to establish database connection with Qt and mysql. The line QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); generates error like below: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC It seems QMYSQL ...

How to change a QPushButton icon when it has focus?

I'm using a QPushButton in an S60 Qt app. I want the button icon to change when it has focus. I've tried this... navButton->setStyleSheet("background-image: url(c:/Data/navArrowsNotSelected.png);"); setStyleSheet("DoubleViewWidget QPushButton:focus {background-image: url(c:/Data/navArrowsSelected.png); border: 2px solid yellow}"); ....

QT: kill current process?

Is there a way in QT to terminate a'la TerminateProcess the current process? QProcess::kill() seem to be only applicable to other, external processes. ...

Create database in QT

Newbie having trouble creating a database here. Following code compiles ok, but no database is created and I can't find any sqlite file. #include "makeDB.h" #include <iostream> #include <QString> #include <QtSql> void makeDB(QString dbName) { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localHost"); ...

C framework like Qt ?

Hi, is there a full-featured framework for C that is similar to Qt? ...

Proper way to check QOject derived class type in Qt

Lets say I have a two classes: class A : public QObject {}; class B : public QObject {}; then I go QObject *a = new A(); QObject *b = new B(); now, how do I make sure that "a" is an instance of class A, and "b" is an instance of class B? currently I do something like this: if (a->inherits(A::staticMetaObject.className())) { ... ...

QT how to use std::string in a QLineEdit

Dear All, I have the following problem. I am trying to integrate a large code written by me with a QT interface. Some of my functions return std::string; I did not succeed in making setText accept them (other functions returning char do not give me problems). What should I do? Thanks! Giuseppe ...

Retrieve revision number in VS with qmake

My current workflow: hg update (or whatever one uses to check out a revision) MyProject.pro → qmake → MyProject.vcproj Open Visual Studio, edit files Build project During the build step, how can I update my config.h header file with information from version control system (e.g. hg id)? MyProject.vcproj is generated by qmake, so I sh...

Qt linguist & google translate

I'm looking for a way to cheat and create some very rough translations of my Qt application using Qt linguist and an already-existing translation service such as google translate. There's a public API for google translate, so I'm hoping someone has already tried this, but I can't seem to find it. Has anyone seen anything like this befor...

C++ static global non-POD: theory and practice

I was reading the Qt coding conventions docs and came upon the following paragraph: Anything that has a constructor or needs to run code to be initialized cannot be used as global object in library code, since it is undefined when that constructor/code will be run (on first usage, on library load, before main() or not at all). Even i...

QGraphicsView with automatic items placing

I would like to write an asset browser using QGraphicsView. It's a little different from examples using QGraphicsView and QGraphicsItems, because I want only one scrollbar and I want items to move automatically, when the viewport size changes. For example, when viewport width is large enough to display 4 asssets, they should be displayed...

How do I use qmake to build multiple binaries in a single project?

I'm writing a small qt app suite that consists of a set of small programs that work on the same set of files. They are organized like this: / app1/ main.cpp app2/ main.cpp app3/ main.cpp common/ project.h project.cpp somemore.h somemore.cpp appsuite.pro When I do qmake && make, I want the follow...

How to control the position of QDialog

Hello Is there any easy way to open the qt dialogs in the same position as they were the last time the application was open ? i.e preserve position of dialogs between application sessions ? Under easy way I understand not to have manually write the window position in file ,and then read :) Thanks ...

Logging facilities and Qt

What logging facilities do you use whit Qt ? Do you choose qDebug(), qWarning(), qCritical(), qFatal() methods, or maybe something like Log4cpp (Log4cplus etc.), or maybe some custom-maked code ? ...

time table / datebook as in Sunbird for Qt?

I would like to implement a calendar in my Qt-based program as it is already implement in Mozilla Sunbird (different colors and categories are important). Is there any "simple" possibility to realize that or do I have to create it all by myself, beginning at zero? Is there a good tutorial to create such a calendar with standards, so tha...

Exception Handling in Qt Script with C++ ?

I have the following action which is executed when a certain button is pressed in a Qt application: #include <shape.h> void computeOperations() { polynomial_t p1("x^2-x*y+1"),p2("x^2+2*y-1"); BoundingBox bx(-4.01, 4.01,-6.01,6.01,-6.01,6.01); Topology3d g(bx); AlgebraicCurve* cv= new AlgebraicCurve(p1,p2); g.push_ba...

QTcpSocket in QThread

I have simple server connection thread. When you call function receiveString, it fails. However when you execute same code in run(), it succeeds. What is needed for function receiveString to work? I've tried both bool TestServerThread::receiveString(QTcpSocket& sock, QString& str) bool TestServerThread::receiveString(QTcpSocket* sock, ...

Stop QNetworkRequest buffering entire request

How can I stop QNetworkRequest from buffering the entire contents of a QIODevice during a put/post to an HTTPS connection? It works fine when posting to HTTP but HTTPS causes the entire file to be read into memory before the post starts. ...