qt

How to fire a JavaScript event via C++ in QWebView

Hi, please note that I'm a complete beginner to Qt development. I have a QWebView with a QObject added to the JavaScript window object. How do I fire a JS event on that object? view->page()->mainFrame()->addToJavaScriptWindowObject(objName,obj); I want to be able to listen to events using addEventListener. window.objName.addEventLis...

Draw over QLabel inside QScrollarea

Hi, I'm developing an image viewer, based on a QScrollArea and a QLabel that contains the image to show. Now, I need to show text over the label, like the current mouse (x,y) position, image size, etc., in a specific point, but it can't be affected by the scrolling. How can I do this? ...

Qt uses CSS to color objects? Is there another way to go about this?

I am learning PyQt from this site. The tutorial is building a widget that colours a square. In this, they are using CSS to colour the square, rather than give it some sort of concrete property of colour. Why is this? Is there another way to do this without CSS or is this the preferred method? It seems awfully strange.. ...

Qt: Advice about dynamic UI

I'm trying to make an UI that contains a list of such items: User can change the count of the items, so the UI is dynamic. What are the best components to get user input, like in the picture? Is it multiple QLabels and QLineEdits? What is the best way to manage them? ...

How to draw an ellipse/circle over QGraphicsScene in a QGraphicsView

Hi, I have a QGraphicsView with a QGraphicsScene. That QGraphicsScene contains a QPixmap. It is possible to drag the scene. On top of that scene I have a HUD with QLabels, QPushButtons and other stuff. When I drag the scene around, the HUD elements never change their position. So far it works all perfect. But now I need to add a new el...

How to "inflate" or "grow" a rectangle in Qt?

Does Qt have a built-in way to inflate or grow a rectangle? Like .NET's Rectangle.Inflate or Java's Rectangle.grow... or do I have to implement my own? I've looked through the docs and couldn't find one but maybe I'm missing something. ...

Install QJson in Mac

Hi, How to install the Qjson in mac? Thanks in advance. ...

When I run my Qt messaging application it stops with exit code -1073741515.

main: #include "QtGui/QApplication" #include "spc_login.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); SPC_LOGIN w; //#if defined(Q_WS_S60) // w.showFullScreen(); //#else // w.show(); //#endif w.showMaximized(); return a.exec(); } ..other code: protected: void changeEv...

Initilizing value for a const data

Following code is in my c++ class static const QString ALARM_ERROR_IMAGE ; i want to initilize ALARM_ERROR_IMAGE = "error.png"; Is it possible to initilize error.png to static const QString ALARM_ERROR_IMAGE Want to keep it inside class ...

How to keep static const variable as a member of a class

Hi, I want to keep a static const variable as a member of class. Is it possible to keep and how can i initilize that variable. Some body helped by saying this QString <ClassName>::ALARM_ERROR_IMAGE = "error.png"; http://stackoverflow.com/questions/3698446/initilizing-value-for-a-const-data I tried like this in CPP class i write...

How to connect a QSqlDatabase using TCP? (Qt's MySQL Driver)

Hello, I am trying to connect to a local MySQL server, but cannot find out how to select if QSqlDatabase should connect through a socket or port. Qt is version 4.6.3. My simple test code is as follows: QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setPort(3306); db.setDatabaseName("rem"); db.set...

How to add an arc to the foreground of a QGraphicsView

Hi, how is it possible to add an QPainter arc to the QGraphicsView foreground. I found QGraphicsView.drawForeground (self, QPainter, QRectF), but I don't understand how to use it. I am new to qt. I also know that it is possible to add an art to the QGraphicsScene, but I need the scene for something else. Or is there an easier way to a...

[Qt] how to retrieve the string of a QUrl with space in it?

QUrl url("bword://blood transfusion"); QString res = url.toString(); Why I got the string "bword:" instead of "bword://blood transfusion"? How can I get the string "bword://blood transfusion" form the QUrl? ...

how to calculate qfont pixel size from point size

How do I convert my font on a QGraphicsObject from point size to pixel size? I need to do this so the fonts will look right when I print my QGraphicsScene using QGraphicsScene::render(). ...

How to get the difference between two QDateTimes in milliseconds?

I wish QDateTime overrode the - operator and returned a QTimeSpan representing the difference between two QDateTimes (just like .NET's TimeSpan). Since this doesn't exist in Qt, I decided to implement it. Unfortunately, QDateTime has no msecsTo-like function. What is the cleanest way to get the difference between two QDateTimes accurate...

Widget display problem in QT?

Hi., i am trying to create layout like this (Please see the Picture) http://i225.photobucket.com/albums/dd200/saravanan_comp2001/layout.jpg In the QT i created widgets and put in the main widget, the problem is not visible. none of the widget's are not shown. please help me to fix this issue Complete Source Code sandbox.ifuturemec.c...

Parsing JSON using QJSON

Hi, My json output look like [{"id":2,"name":"AAA"},{"id":1,"name":"BBB"}]. I want to parse this using Qjson in mac. I am trying to parsing but I could not get any outputs . please help me. Thanks in advance. ...

Converting an image to text

Hey everyone, I want to be able to save an image as text in a xml file and I can't manage to find a efficient way to do it ! So far I tried : QByteArray ImageAsByteArray; QBuffer ImageBuffer(&ImageAsByteArray); ImageBuffer.open(QIODevice::WriteOnly); rImage.save(&ImageBuffer, "PNG"); return QString(ImageAsByteArray.toBase64()); D...

Best way to graphically represent a tree node in Qt

Hello, I'm trying to visualise a tree in Qt. So far, all my nodes consist of simple circles and based on QGraphicsItem class. But I need to display some text over every node, how can I "attach" a QLabel to my nodes? Thanks in advance. ...

How to reduce Qt's output size based on application usage

Hi all, I've recently been looking at Qt, and yes I should have started a long time ago... But the issue has come up that the prebuilt or self compiled .dlls, QtCore4.dll, QtGui4.dll, etc., are quite large. Since I must stay within the LGPL, is there a correct way to only link in what I need into the QtCore4.dll and QtGui4.dll files so...