I know how to apply a keyboard shortcut to an action. And in some software such as Visual Studio there are shortcuts that do the job in more than one step (such as Ctrl+K,Ctrl+C to comment the code).
Another example of that in Sublime Text:
I wonder whether or not it is possible to implement in Qt.
You can create it by using the multiple arguments constructor for QKeySequence.
like this:
auto ac = new QAction(this);
ac->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K, Qt::CTRL + Qt::Key_C));
Try this:
action->setShortcut("Ctrl+K,Ctrl+C");
QKeySequence may be implicitly created from QString.
Due to documentation:
Up to four key codes may be entered by separating them with commas, e.g. "Alt+X,Ctrl+S,Q".
MOC generates almost same code when you create shortcut for a QAction via Qt Designer. But it makes it slightly different:
action->setShortcut(QApplication::translate("MainWindow", "Ctrl+K, Ctrl+C", 0));
but it's actually same thing.
You can use eventFilter to get mouse & keyboard events.
I use boolean to get first and second key, Ctrl + K then C.
I made you a sample code it's working.
.cpp file:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
firstKey = false;
secondKey = false;
this->installEventFilter(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
if (object == this &&event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ((keyEvent->key() == Qt::Key_Control))
{
firstKey = true;
return true;
}
else if ((keyEvent->key() == Qt::Key_K))
{
secondKey = true;
return true;
}
else if ((keyEvent->key() == Qt::Key_C))
{
if(firstKey && secondKey)
{
firstKey = false;
secondKey = false;
QMessageBox::information(this, "", "Ctrl + k + c");
}
return true;
}
else
return false;
}
else
return false;
}
void MainWindow::keyReleaseEvent(QKeyEvent *e)
{
if (e->type() == QEvent::KeyRelease)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if ((keyEvent->key() == Qt::Key_Control))
{
firstKey = false;
}
}
}
.h file:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QMessageBox>
#include <QKeyEvent>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
bool firstKey;
bool secondKey;
bool eventFilter(QObject *object, QEvent *event);
void keyReleaseEvent(QKeyEvent *e);
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
Related
I want to draw a line using QGraphicsLineItem. What exactly I want is that on clicking at GraphicsView, after second click Line must be drawn. I am confused with the syntax of QGraphicsLineItem and also how to use it. I am new to Qt. Please help me out to solve this problem.
You can use this code snippet.
*h
#ifndef GRAPHICSSCENE_H
#define GRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QStack>
#include <QPoint>
#include <QMouseEvent>
class GraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
explicit GraphicsScene(QObject *parent = 0);
signals:
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
public slots:
private:
QStack<QPoint> stack;
};
#endif // GRAPHICSSCENE_H
*.cpp
#include "graphicsscene.h"
#include <QDebug>
#include <QGraphicsSceneMouseEvent>
GraphicsScene::GraphicsScene(QObject *parent) :
QGraphicsScene(parent)
{
}
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
qDebug() << "in";
if (mouseEvent->button() == Qt::LeftButton)
{
QPoint pos = mouseEvent->scenePos().toPoint();
if(stack.isEmpty())
stack.append(pos);
else if(stack.count() == 1)
{
stack.append(pos);
addLine(QLine(stack.pop(),stack.pop()),QPen(Qt::green));
}
}
}
Usage:
GraphicsScene *scene = new GraphicsScene(this);
ui->graphicsView->setScene(scene);
ui->graphicsView->show();
Edit: more beautiful solution which works as you need.
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
qDebug() << "in";
if (mouseEvent->button() == Qt::LeftButton)
{
QPoint pos = mouseEvent->scenePos().toPoint();
if(stack.isEmpty())
stack.append(pos);
else
addLine(QLine(pos,stack.pop()),QPen(Qt::green));
}
}
You can derive the graphics view/scene and override the mousePressEvent
Below is example using derived QGraphicsScene and overridden mousePressEvent
Class Definition :
class MyScene : public QGraphicsScene
Data Members :
QList<QPointF> m_clickPositions;
int m_mode;
Code :
void MyScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(false == sceneRect().contains(event->scenePos()))
{
QGraphicsScene::mousePressEvent(event);
}
else if(Qt::LeftButton == event->button() && m_mode == ConstructMode)
{
m_clickPositions.append(event->scenePos());
if(m_clickPositions.size() == 2)
{
QLineF lineF(m_clickPositions[0], m_clickPositions[1]);
QGraphicsLineItem* item = this->addLine(lineF);
m_clickPositions.clear();
m_mode = ScrollMode;
}
}
}
I had used something similar in my project and extracted the code. Hope this helps.
Please comment is this is not working.
Edit ::
ConstructMode and Scroll mode are used in the above program so that I can distinguish whether I want to Draw/Construct or just scroll the scene. You can remove them and the declaration of m_mode if not required by you.
If you want to use the modes you can define some public constants and add a method setMode(). Please see the code below.
MyScene.h or some Constant file if you have one
#define ConstructMode 100
#define ScrollMode 101
And add the following function
void MyScene::setMode(int mode)
{
m_mode = mode;
}
After this if you want to enter the construction mode you will need to call myScene->setMode(ConstructMode) everytime, as after the item is constructed the mode is reset to ScrollMode.
I am trying to handle mult-itouch events in this simple QWidget based program but not able to receive any touch events.
"MyWidget.h"
#include <QWidget>
class QPaintEvent;
class QEvent;
class MyWidget : public QWidget
{
Q_OBJECT
public:
explicit MyWidget(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *);
bool event ( QEvent * event );
};
"MyWidget.cpp"
MyWidget::MyWidget(QWidget *parent) :
QWidget(parent)
{
setAttribute(Qt::WA_AcceptTouchEvents);
}
void MyWidget::paintEvent(QPaintEvent *evt) {
QPainter painter(this);
painter.fillRect(rect(),QColor(0,255,0));
// painter.drawText(QPoint(rect().left(),rect().top()),"Hello world");
}
bool MyWidget::event(QEvent *event){
if(event->type() == QEvent::TouchBegin ||
event->type() == QEvent::TouchEnd ||
event->type() == QEvent::TouchUpdate ){
qDebug() <<"Touch events";
}
else if(event->type() == QEvent::MouseButtonDblClick) {
qDebug() <<"double click";
}
return QWidget::event(event);
}
Am I missing anything here ?
To make touch events work add the following to your MainWindow:
MyWidget *myWidget = ...;
setCentralWidget(myWidget);
In the MyWidget constructor add:
setAttribute(Qt::WA_AcceptTouchEvents);
//grabGesture(Qt::PinchGesture);
//setAttribute(Qt::WA_InputMethodEnabled);
//setFocusPolicy(Qt::WheelFocus);
setAttribute(Qt::WA_StaticContents);
I'm aware I need to derive from QObject in order to connect to a slot if I am using QGraphicsPixmapItem, but I am struggling to do this. I have tried alternative ways to achieve what I want, I have tried onMousePress and isSelectable i.e.
run->setFlag(QGraphicsPixmapItem::ItemIsSelectable);
if (run->isSelected())
{
qDebug() << "selected";
}
else if (!run->isSelected())
{
qDebug() << "not selected";
}
although run is selectable, the first argument is never true, it is always "not selected"
This is my code, I am working on the slot method;
mainwindow.cpp
int MainWindow::sim()
{
...
QGraphicsPixmapItem* run = new QGraphicsPixmapItem(QPixmap::fromImage(image6));
run->scale(0.3,0.3);
run->setPos(-200,-200);
run->setFlag(QGraphicsPixmapItem::ItemIsSelectable);
run->setCursor(Qt::PointingHandCursor);
connect(run, SIGNAL(selectionChanged()), this, SLOT(runClicked()));
scene->addItem(run);
//pause
QGraphicsPixmapItem* pause = new QGraphicsPixmapItem(QPixmap::fromImage(image7));
pause->scale(0.3,0.3);
pause->setPos(-160,-197);
pause->setFlag(QGraphicsPixmapItem::ItemIsSelectable);
pause->setCursor(Qt::PointingHandCursor);
connect(pause, SIGNAL(selectionChanged()), this, SLOT(pauseClicked()));
scene->addItem(pause);
...
}
void MainWindow::runClicked()
{
qDebug() << "run Clicked";
}
void MainWindow::pauseClicked()
{
qDebug() << "pause Clicked";
}
mainwindow.h
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
int sim();
...
public slots:
void runClicked();
void pauseClicked();
...
So obviously I get the error when connecting to the slots. Could anyone help please? Thank you.
To find out if your item is selected, do this:
QVariant MyItem::itemChange( GraphicsItemChange change, const QVariant& value )
{
if ( change == QGraphicsItem::ItemSelectedHasChanged ) {
qDebug() << ( isSelected() ? "selected" : "not selected" );
}
return QGraphicsItem::itemChange( change, value );
}
If you want to use signals and slots, you need to subclass both QObject and QGraphicsPixmapItem.
Because QObject doesn't contain clicked() signal, you need to implement that, too, by re-implementing
void mousePressEvent ( QGraphicsSceneMouseEvent *e ) and void mouseReleaseEvent ( QGraphicsSceneMouseEvent *e ).
MyItem:
#pragma once
#include <QGraphicsPixmapItem>
#include <qobject.h>
#include <QMouseEvent>
#include <QGraphicsSceneMouseEvent>
class MyItem: public QObject, public QGraphicsPixmapItem
/* moc.exe requires to derive from QObject first! */
{
Q_OBJECT
public:
MyItem(QGraphicsItem *parent = 0): QObject(), QGraphicsPixmapItem(parent)
{
}
MyItem(const QPixmap & pixmap, QGraphicsItem * parent = 0 ): QObject(),
QGraphicsPixmapItem(pixmap, parent)
{
}
signals:
void clicked();
protected:
// re-implement processing of mouse events
void mouseReleaseEvent ( QGraphicsSceneMouseEvent *e )
{
// check if cursor not moved since click beginning
if ((m_mouseClick) && (e->pos() == m_lastPoint))
{
// do something: for example emit Click signal
emit clicked();
}
}
void mousePressEvent ( QGraphicsSceneMouseEvent *e )
{
// store click position
m_lastPoint = e->pos();
// set the flag meaning "click begin"
m_mouseClick = true;
}
private:
bool m_mouseClick;
QPointF m_lastPoint;
};
And simple example of usage:
#include <qgraphicsview.h>
#include <qgraphicsscene.h>
#include "reader.h"
#include <qdebug.h>
class MainAppClass: public QObject
{
Q_OBJECT
public:
MainAppClass()
{
QGraphicsScene *scene = new QGraphicsScene();;
scene->setSceneRect( -100.0, -100.0, 200.0, 200.0 );
MyItem *item = new MyItem(QPixmap("about.png"));
connect(item, SIGNAL(clicked()), this, SLOT(pixmapClicked()));
scene->addItem(item);
QGraphicsView * view = new QGraphicsView( scene );
view->setRenderHints( QPainter::Antialiasing );
view->show();
}
public slots:
void pixmapClicked()
{
qDebug() << "item clicked!" ;
}
};
I'm using QFileDialog to select a directory. I'm having an issue that I'm unable to resolve. I've spent a lot of time googling for this but have come up with zilch.
I specify the starting directory (say /home/dhoti/downloads) and I want to disable navigation above this directory. For example the user should not be allowed to go to /home/dhoti or /tmp etc. How do I achieve this?
Here is my code:
QFileDialog dlg(this, "Select Firmware Version");
dlg.setDirectory("/home/dhoti/downloads");
dlg.setFileMode(QFileDialog::DirectoryOnly);
dlg.setOption(QFileDialog::ReadOnly, true);
dlg.setOption(QFileDialog::HideNameFilterDetails, true);
dlg.setViewMode(QFileDialog::List);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.exec();
qDebug() << "selected files: " << dlg.selectedFiles();
thanks for any help
Dhoti
You can detect when the current directory changes and if it is beyond your limit, set the directory back to the limit directory.
You can do this by executing the dialog non-blocking, and connecting the QFileDialog::directoryEntered(const QString& directory) signal to a slot of your own where you can do the checking. If it fails your check, set the current directory to the limit directory by QFileDialog::setDirectory(const QString& directory).
Disclaimer I have not tried this, but I'll be surprised if it does not work.
Try the following:
filedialog.h
#ifndef FILEDIALOG_H
#define FILEDIALOG_H
class QEvent;
#include <QFileDialog>
#include <QString>
class FileDialog : public QFileDialog
{
Q_OBJECT
public:
explicit FileDialog(QWidget *parent = 0);
public:
bool eventFilter(QObject *o, QEvent *e);
void setTopDir(const QString &path);
QString topDir() const;
private:
bool pathFits(const QString &path) const;
private slots:
void checkHistory();
void checkGoToParent();
void checkLineEdit(const QString &text);
private:
QString mtopDir;
};
#endif // FILEDIALOG_H
filedialog.cpp
#include "filedialog.h"
#include <QString>
#include <QStringList>
#include <QFileDialog>
#include <QList>
#include <QToolButton>
#include <QDir>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QEvent>
#include <QKeyEvent>
#include <QAbstractButton>
#include <QCompleter>
#include <QAbstractItemView>
#include <QFileInfo>
FileDialog::FileDialog(QWidget *parent) :
QFileDialog(parent)
{
connect(this, SIGNAL(directoryEntered(QString)), this, SLOT(checkHistory()));
connect(this, SIGNAL(directoryEntered(QString)), this, SLOT(checkGoToParent()));
connect(findChild<QToolButton *>("backButton"), SIGNAL(clicked()), this, SLOT(checkGoToParent()));
connect(findChild<QToolButton *>("forwardButton"), SIGNAL(clicked()), this, SLOT(checkGoToParent()));
connect(findChild<QLineEdit *>("fileNameEdit"), SIGNAL(textChanged(QString)), this, SLOT(checkLineEdit(QString)));
findChild<QLineEdit *>("fileNameEdit")->installEventFilter(this);
findChild<QWidget *>("listView")->installEventFilter(this);
findChild<QWidget *>("treeView")->installEventFilter(this);
findChild<QLineEdit *>("fileNameEdit")->completer()->popup()->installEventFilter(this);
setOption(DontUseNativeDialog, true);
}
bool FileDialog::eventFilter(QObject *o, QEvent *e)
{
if (e->type() != QEvent::KeyPress)
return false;
int key = static_cast<QKeyEvent *>(e)->key();
if (o->objectName() == "listView" || o->objectName() == "treeView")
{
return (Qt::Key_Backspace == key && !pathFits(directory().absolutePath()));
}
else
{
if (Qt::Key_Return != key && Qt::Key_Enter != key)
return false;
QString text = findChild<QLineEdit *>("fileNameEdit")->text();
QString path = QDir::cleanPath(directory().absolutePath() + (text.startsWith("/") ? "" : "/") + text);
bool a = QDir(text).isAbsolute();
return !((!a && pathFits(path)) || (a && pathFits(text)));
}
}
void FileDialog::setTopDir(const QString &path)
{
if (path == mtopDir)
return;
mtopDir = (!path.isEmpty() && QFileInfo(path).isDir()) ? path : QString();
if (!pathFits(path))
{
setDirectory(mtopDir);
checkHistory();
checkLineEdit(findChild<QLineEdit *>("fileNameEdit")->text());
}
else
{
QLineEdit *ledt = findChild<QLineEdit *>("fileNameEdit");
ledt->setText(ledt->text());
}
findChild<QWidget *>("lookInCombo")->setEnabled(mtopDir.isEmpty());
findChild<QWidget *>("sidebar")->setEnabled(mtopDir.isEmpty());
checkGoToParent();
}
QString FileDialog::topDir() const
{
return mtopDir;
}
bool FileDialog::pathFits(const QString &path) const
{
return mtopDir.isEmpty() || (path.startsWith(mtopDir) && path.length() > mtopDir.length());
}
void FileDialog::checkHistory()
{
QStringList list = history();
for (int i = list.size() - 1; i >= 0; --i)
if (!pathFits(list.at(i)))
list.removeAt(i);
setHistory(list);
}
void FileDialog::checkGoToParent()
{
findChild<QToolButton *>("toParentButton")->setEnabled(pathFits(directory().absolutePath()));
}
void FileDialog::checkLineEdit(const QString &text)
{
QAbstractButton *btn = findChild<QDialogButtonBox *>("buttonBox")->buttons().first();
QString path = QDir::cleanPath(directory().absolutePath() + (text.startsWith("/") ? "" : "/") + text);
bool a = QDir(text).isAbsolute();
btn->setEnabled(btn->isEnabled() && ((!a && pathFits(path)) || (a && pathFits(text))));
}
This code may look like some magic, and it's not perfect, but it works. I searched for QFileDialog child objects names in Qt sources and used
findChild()
method to access them. All you need is just use the
setTopDir()
method to specify a directory above which users are not allowed to go.
Here's an example project using this class: https://docs.google.com/file/d/0B3P3dwuDIZ1-Q19FbkFMY2puUE0/edit?usp=sharing
You can use the solution of #ololoepepe. And clean unwanted entries in the comboBox on the top with this:
connect(findChild<QComboBox *>("lookInCombo"), static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FileDialog::checkComboBox);
void FileDialog::checkComboBox(int index) {
int i;
QComboBox *cb = findChild<QComboBox *>("lookInCombo");
if (index == 0 && cb->model()->rowCount() > 1) {
for (i = 0; i < cb->model()->rowCount(); ++i) {
if (!pathFits(cb->model()->index(i, 0).data().toString() + "/")) {
cb->model()->removeRow(i);
--i;
}
}
}
}
Here is the simplest solution, with the minimum steps required to limit a directory traversal.
Idea: use public signal directoryEntered(const QString &) of QFileDialog to get notification when directory might be changed, implement slot for it in one of your classes and place there a logic for making sure that directory is the one you need.
QFileDialog dialog(this);
connect(&dialog, SIGNAL(directoryEntered(const QString &)), this, SLOT(onFileDialogDirectoryChanged(const QString &)));
I'm new to Qt/Symbian development (I come from an iOS background), and I can't make sense of this compiler error:
Firstly, this is the error I'm getting:
/Users/Dave/AR-build-simulator/../QtSDK/Simulator/QtMobility/gcc/include/QtSensors/qsensor.h:-1: In member function 'QtMobility::QMagnetometerReading& QtMobility::QMagnetometerReading::operator=(const QtMobility::QMagnetometerReading&)':
Here is my header file:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
#include <QSystemDeviceInfo>
#include <QGeoPositionInfoSource>
#include <QGeoCoordinate>
#include <QGeoPositionInfo>
#include <QMagnetometer>
QTM_USE_NAMESPACE
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
enum ScreenOrientation {
ScreenOrientationLockPortrait,
ScreenOrientationLockLandscape,
ScreenOrientationAuto
};
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
// Note that this will only have an effect on Symbian and Fremantle.
void setOrientation(ScreenOrientation orientation);
void showExpanded();
private slots:
void positionUpdated(QGeoPositionInfo gpsPos);
void magnetometerReadingChanged(QMagnetometerReading mr);
private:
Ui::MainWindow *ui;
void setupGeneral();
QGeoPositionInfoSource *m_location;
QGeoCoordinate m_coordinate;
QMagnetometer *m_magnetometer;
QMagnetometerReading m_magnetometerReading;
};
#endif // MAINWINDOW_H
Here is the implementation file:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtCore/QCoreApplication>
#include <qgeopositioninfosource.h>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
setupGeneral();
}
void MainWindow::setupGeneral()
{
m_location = QGeoPositionInfoSource::createDefaultSource(this);
//Listen to gps position changes
QObject::connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this,SLOT(positionUpdated(QGeoPositionInfo)));
//Start listening to GPS position updates
m_location->startUpdates();
//Start listening to magnetometer updates
m_magnetometer = new QMagnetometer(this);
connect(m_magnetometer, SIGNAL(readingChanged(QMagnetometerReading)), this, SLOT(magnetometerReadingChanged(QMagnetometerReading)));
m_magnetometer->start();
}
void MainWindow::positionUpdated(QGeoPositionInfo gpsPos){
m_coordinate = gpsPos.coordinate();
if (m_coordinate.isValid()) {
m_location->stopUpdates();
QString longitude;
QString latitude;
longitude.setNum(m_coordinate.longitude());
latitude.setNum(m_coordinate.latitude());
QMessageBox::information(this,"latitude",latitude);
} else {
QMessageBox::information(this, "GPS Info", "Coordinator is not valid...");
}
}
void MainWindow::magnetometerReadingChanged(QMagnetometerReading mr) {
QMessageBox::information(this, "Magnetometer info", "got magnetometer reading...");
m_magnetometerReading = mr;
//m_magnetometerReading = new QMagnetometerReading(this);
//m_magnetometerReading->copyValuesFrom(mr);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setOrientation(ScreenOrientation orientation)
{
#if defined(Q_OS_SYMBIAN)
// If the version of Qt on the device is < 4.7.2, that attribute won't work
if (orientation != ScreenOrientationAuto) {
const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
return;
}
}
#endif // Q_OS_SYMBIAN
Qt::WidgetAttribute attribute;
switch (orientation) {
#if QT_VERSION < 0x040702
// Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
case ScreenOrientationLockPortrait:
attribute = static_cast<Qt::WidgetAttribute>(128);
break;
case ScreenOrientationLockLandscape:
attribute = static_cast<Qt::WidgetAttribute>(129);
break;
default:
case ScreenOrientationAuto:
attribute = static_cast<Qt::WidgetAttribute>(130);
break;
#else // QT_VERSION < 0x040702
case ScreenOrientationLockPortrait:
attribute = Qt::WA_LockPortraitOrientation;
break;
case ScreenOrientationLockLandscape:
attribute = Qt::WA_LockLandscapeOrientation;
break;
default:
case ScreenOrientationAuto:
attribute = Qt::WA_AutoOrientation;
break;
#endif // QT_VERSION < 0x040702
};
setAttribute(attribute, true);
}
void MainWindow::showExpanded()
{
#ifdef Q_OS_SYMBIAN
showFullScreen();
#elif defined(Q_WS_MAEMO_5)
showMaximized();
#else
show();
#endif
}
If anybody could explain to me what is going wrong, I'd be very grateful.
According to the documentation(here) readingChanged signal does not have any parameters. You should use
connect(m_magnetometer, SIGNAL(readingChanged()), this, SLOT(magnetometerReadingChanged())); and then acquire the reading from the reading property.