qt4

QFileDialog: adding extension automatically when saving file?

When using a QFileDialog to save a file and to specify the extension (like *.pdf) and the user types in a name without this extension, also the saved file hasn't this extension. Example-Code: QFileDialog fileDialog(this, "Choose file to save"); fileDialog.setNameFilter("PDF-Files (*.pdf)"); fileDialog.exec(); QFile pdfFile(fileDialog.se...

Using Custom Events in QT4

I have an app that has a progress bar & spawns a worker thread to do some work & report back progress. The dialog class overrides the customEvent method so that I can process events that are being passed to the gui thread via the worker thread. Before I was using a QThread derived class as the worker thread and I changed it to use ACE_...

Qt4.5 vs Cocoa for native Mac UI

Hey guys, I've been developing for Windows and *nix platforms for quite some time, and am looking to move into Mac development. I am tossing up between using ObjC/Cocoa and C++/Qt4.5. The C++/moc semantics make more sense to me, and improving knowledge in Qt seems like a sensible thing to do given that you end up with a skill set that ...

Help with qt4 qgraphicsview

I've done lots of stuff with pygtk however i'm deciding to learn pyqt, im stuck at the qgraphicsview i have absolutley no idea how to get signals from the items i place on the graphics view, primarily mouse events.How do i get the mouse events from idividual items in a scene? ...

Adding Vertical headers to a QTreeView

I have a QTreeView subclass (and QAbstractItemModel subclass) which has a nice horizontal header. I would like to add vertical headers (going down the left side) to match. But unlike QTableView which has separate vertical (setVerticalHeader()) and horizontal headers (setHorizontalHeader()), QTreeView only allows a single header (setHeade...

Large number of simultaneous long-running operations in Qt

I have some long-running operations that number in the hundreds. At the moment they are each on their own thread. My main goal in using threads is not to speed these operations up. The more important thing in this case is that they appear to run simultaneously. I'm aware of cooperative multitasking and fibers. However, I'm trying to...

Porting threads from QT3 to QT4

I am porting an application from QT3 to QT4, and keep running into problems when a thread is updating a QProgressDialog. The original code was roughly designed like so: class ScanProcess : QObject{ Q_OBJECT public: QProgressDialog* progress; private: ScanProcessThread* thread; }; class ScanProcessThread : QThread { Q_OBJECT public:...

List machine's serial ports [Qt4]

I have an arduino-based device which connects through USB. I'd like to detect it from my Qt4 application, using QExtSerialPort (or whatever necessary), when it's plugged in. If this weren't possible, I thought I could somehow get a list of the system's port names and just try all of them in search for my arduino (where I'd implement s...

Why is this error: reference to ‘statusBar’ is ambiguous.. coming? Is this a bug?

I created a QMainWindow using QT Designer. As we know, it has statusBar by default. By default, QT Designer gave its objectname as "statusBar". Now, when I tried to call like:- statusBar()->showMessage(tr("File successfully loaded."), 3000); as we have a function with prototype: QStatusBar * QMainWindow::statusBar () const The Comp...

Using multiple QStyledItemDelegate with stylesheets

I'm creating a styled QTreeView using double-dispatch to resolve specific delegate for data items, which is working great. I subclassed the delegates from QStyledItemDelegate to take advantage of stylesheets, enabling the designers to style the UI outside of the code. Unfortunately, I have been unable to address different styles from...

Scrolling different Widgets at the same time

Hi all! I have different types of QWidgets into a DockWindow: 1 Qwt plot 1 QWidget 3 QGraphicsView And I need scrolling all of them at the same time with the same scrollbar when I zoom in. I know two solutions for this: Create one scrollbar and connect it to each widget. Create one scrollArea and manipulate all the widgets. What...

setCentralWidget() causing the QMainWindow to crash.. Why?

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->setupUi(this); this->setupActions(); this->setWindowTitle(tr("CuteEdit")); label = new QLabel(tr("No Open Files")); this->setCentralWidget(label); label->setAlignment(Qt::AlignCenter); } By above code, I get a GUI like ...

Question about Qt slots and multiple calls

I am just learning Qt and have a very basic question. If there is a (function scope) variable in a slot, and the slot is called multiple times, each time before the last call has returned (is this even possible?), will the variable be overwritten each time? In the sense that, if the slot is called before the previous run has returned, ...

Qt4 Stylesheets and Focus Rect

I would like to use a stylesheet :focus pseudo-state to control the representation of the Tree view's focus state. Using the following stylesheet works well, except that the Qt system still draws it's own focus rect. How do I ask Qt to not draw the focus rect, while still being able to focus the control for keyboard input? QTreeView {...

Order of QObject children (strategy question)

For one of my projects I have a tree of QObject derived objects, which utilize QObject's parent/child functionality to build the tree. This is very useful, since I make use of signals and slots, use Qt's guarded pointers and expect parent objects to delete children when they are deleted. So far so good. Unfortunately now my project req...

python qt raise syntax error

I have a top level widget that is producing a syntax error in python. raise() on line 15. This is using the python Qt bindings. I know that raise is a python reserved word. I am looking for how to call the Qt "raise()" function with the python bindings. #!/usr/bin/python # simple.py import sys from PyQt4 import QtGui app = QtGui...

How to do precise mouse event handling in QGraphicsScene when ItemClipsChildrenToShape is enabled?

I have a QGraphicsItem that clips its child items (I enabled its ItemClipsChildrenToShape flag). I noticed that clipping makes assigning the mouse event to the children items imprecise: instead of the precise shape of the items their bounding rectangles are used for detecting which item is located at the specific position so the children...

Why does my QGraphicsView not showing up in my MainWindow in Qt4?

This is probably something very obvious, but I have a new to Qt and can't figure it out. I have a simple MainWindow which has one button. When that button is clicked I want to create a QGraphicsScene, add a few lines and then show that in the Window. However when I run this code in a Window it does not show up. BUT, if I run this as a ...

PyQt, click action on Qwidget

Hi I've this simple problem, I can grab the event of a click on button, but now I need to handle a click over a widget, here is part of the code: self.widget = QtGui.QWidget(self) self.widget.setStyleSheet("QWidget { background-color: %s }" % color.name()) self.widget.setGeometry(150, 22, 50, 50) self.connect(???) well, what should i...

Problem with detecting phone orientation change in Symbian/Qt

I want to do some custom processing when the orientation of the phone changes. I have re-implemented the resizeEvent(QResizeEvent*) virtual function in my class. The strange thing is, for the first one time when the phone orientation is changed, this function is actually called, and works fine. But all subsequent orientation changes, t...