qt

QTreeWidget set height of each row depending on content

Hi everyone, I want to make editable cells with multi-lines content in QTreeWidget and I use for this purpose QPlainTextEdit as a delegate. I need to set proper size to all rows that switching between editing and displaying went smooth, without any visible changes. rect = textEdit.blockBoundingRect(textEdit.firstVisibleBlock()) wit...

Qt inheriting from QGraphicsEllipseItem

I was trying to inherit from QGraphicsEllipseItem 'cause i wanted to add some functionality to it. However i was faced with this error, which probably has something to do with the compiler/precompiler or moc? error: 'staticMetaObject' is not a member of 'QGraphicsEllipseItem' And here's the class code: class MyEllipseItem : public ...

QListView how to add column ?

How can I add columns to QListView control. Found a method addColumn while seardhing, but in my Qt Creator 1.2.1 based on Qt 4.5.2(32 bit) QListView doesn't have such method at all !!! So how would I add columns ? Say I have 3 columns then what is the code to add a row ? ...

QWebView loadFinished signal catching all responses even from different

Hello all im using one main QNetworkAccessManager that is in singleton class every time some part from the application that looks like this : NetWorkService::NetWorkService() { manager = new QNetworkAccessManager(); } QNetworkAccessManager* NetWorkService::getManager() { return manager; } needs to preform http call it call...

At what point is it worth using a database?

I have a question relating to databases and at what point is worth diving into one. I am primarily an embedded engineer, but I am writing an application using Qt to interface with our controller. We are at an odd point where we have enough data that it would be feasible to implement a database (around 700+ items and growing) to manage...

Playing Multiple Sounds at Once in Qt

I'm trying to play background music along with sound effects using Qt. However, I can't get more than one sound to play at once. For example: QSound::play("Music.wav"); QSound::play("Effect.wav"); When this code is run (on Windows), you can hear Music.wav just start to play, but then it stops and Effect.wav plays. Is there any way to ...

QT widget for on WindowsXP

Hi Geeks, I need to create a widget which shows battery status(in percentage) inside my qt application. Can anybody suggest me how to get the winXP api to know the battery status. Then as the api will return the percentage I will display on my widget.... ...

PyQt error: QSqlDatabasePrivate::database: unable to open database

What is the cause of following error: QSqlDatabasePrivate::database: unable to open database: unable to open database file Error opening database? Code is 100% correct, this message appeared when I have reinstalled Windows, Python and PyQt. EDIT: I have "read-only" flag in folder with .db file properties. It stays gray (half-checked) w...

How to get selected listitem index in Qt

Hi all, I am having a QListView which having some items. Now i want to get the index of selected item. i.e. if i select 5th element i should get 5. How i can get this?.. waiting for reply. Thanks in advance -S ...

java equivalent panels in qt

hello i would like to know the java panel equivalent in qt..i mean which class we need to use in qt,i.e.. qframe or qwidget..i need to add many panels to my qt mainwindow ...

QtScript: Passing an array of objects to C++

Hi, I want to pass an array of objects from my QtScript to C++ but I have not been able to figure out how to achieve this. As soon as I create an array, the elements inside it are converted to strings before I can access them. This is what I have been trying so far: class myObject : public QObject, public QScriptable { Q_OBJECT ...

How do I copy object in Qt?

I'm using Qt and have some real basic problems. I have created my own widget MyTest that have a variable obj. I need to set this variable obj from an object outside of the widget so that the variable is copied not just a pointer to another object. I get an error message and can't figure out how to do this basic stuff. This is the code I'...

resizing row's height in QTreeWidget/QTreeView

Hi everyone, I have some problems with sizing row's height in QTreeWidget. I use QStyledItemDelegate with QPlainTextEdit. During editing text in QPlainTextEdit i check for changes with a help of: rect = self.blockBoundingRect(self.firstVisibleBlock()) and if text's height changes i resize editor size and need row in QTreeWidget also ...

How to uncompress in QT/C++ the data compressed in PHP (gzcompres)

I have a compressed string written by PHP gzcompress($string) I need to read it with C++ on QT. Any help is very appreciated! ...

Qt: Force QWebView to click on a web element, even one not visible on the window

So let's say I'm trying to click a link in the QWebView, here is what I have: // extending QWebView void MyWebView::click(const QString &selectorQuery) { QWebElement el = this->page()->mainFrame()->findFirstElement(selectorQuery); if (!el) return; el.setFocus(); QMouseEvent pressEvent(QMouseEvent::MouseButtonP...

Qt: How to autoexpand parents of a new QTreeView item when using a QSortFilterProxyModel

I'm making an app wherein the user can add new data to a QTreeModel at any time. The parent under which it gets placed is automatically expanded to show the new item: self.tree = DiceModel(headers) self.treeView.setModel(self.tree) expand_node = self.tree.addRoll() #addRoll makes a node, adds it, and returns the (parent) note to be expa...

Qt/C++ or C#, which learn first??

I already know C++ console programming. So shall i learn Qt for c++ or c# first?? I eventually plan to learn both anyways. Also, how long will each one take. The only programming language i know is c++. ...

C++ smart pointers: sharing pointers vs. sharing data

In this insightful article, one of the Qt programmers tries to explain the different kinds of smart pointers Qt implements. In the beginning, he makes a distinction between sharing data and sharing the pointers themselves: First, let’s get one thing straight: there’s a difference between sharing pointers and sharing data. When yo...

My QFileSystemModel doesn't work as expected in PyQt

EDIT2: model.hasChildren(parentIndex) returns True, but model.rowCount(parentIndex) returns 0. Is QFileSystemModel just fubar in PyQt? EDIT: With a bit of adaptation this all works exactly as it should if I use QDirModel. This is deprecated, but maybe QFileSystemModel hasn't been fully implemented in PyQt? I'm learning the Qt Model/V...

Qt double click check left button mouse

I need to run slot only on doubleClick with left button mouse, instead of both. connect(this -> myComponent, SIGNAL (doubleClicked (const QModelIndex & )), this, SLOT (performSomeAction(const QModelIndex & ))); With this event, double click works in both cases, but needed only with left button click. How I can do it? this -> myComp...