qt4

How to get which QradioButton invoke the SLOT

那年仲夏 提交于 2019-12-11 03:02:10
问题 I create several QradioButton and connect to the same SLOT. In the slot, I want to know which QradioButton invoke the slot and do the related action. I found there is a way by using qobject_cast and QObject::sender(), but it seems not work. Here is the code: header file: class dialoginput : public QDialog { Q_OBJECT public: dialoginput(QWidget *parent = 0); QRadioButton *radio1; QRadioButton *radio2; QRadioButton *radio3; private slots: void setText_2(); private: QLabel *label_0_0; QLabel

how to avoid paintevent() being called when the widget was obscured and uncovered

社会主义新天地 提交于 2019-12-11 02:26:28
问题 i want to draw some rhombuses with random colors in a Qwidget . The widget should be repainted only when the window is resized .The problem is that when the widget was obscured and has now been uncovered , it is repainted. How can i avoid calling paintEvent() in this case? Thanks in advance. void Dialog::paintEvent(QPaintEvent *e) { QPainter painter(this); QRect background(0,0,this->geometry().width(),this->geometry().height()); painter.setBrush( QBrush( Qt::white ) ); painter.setPen( Qt:

QGraphicsPixmapItem not selectable

試著忘記壹切 提交于 2019-12-11 02:21:35
问题 I want my QGraphicsPixmapItem become selectable (i.e. clickable in more general way) on QGraphicScene but it doesn't. I'm actually modifying Qt 's Diagram Scene sample, where QGraphicsItem 's subclass is used and is selectable. I appreciate your help. cpp code (partial): #include <iostream> #include <QtGui> #include "overlayPixmapItem.h" OverlayPixmapItem::OverlayPixmapItem(DiagramType diagramType, QMenu *contextMenu, QPixmap img, QGraphicsItem *parent, QGraphicsScene *scene) :

QFileDialog : how to set option to show content of folder in getExistingDirectory()

不羁的心 提交于 2019-12-11 01:29:51
问题 I am using QFileDialog as filename = QFileDialog::getExistingDirectory(this,"Select Image File: ",dataDir,0); I want that I can check files inside folder before selecting it. function getExistingDirectory() is setting QFileDialog::ShowDirsOnly as a default option. I checked in docs there is no any option that do opposite of this. So I set last parameter 0. But now it is not using native dialog. I want to use native dialog with this. I have no clue how to do this cause no flag found in options

Why isn't QString::localeAwareCompare() working correctly

别来无恙 提交于 2019-12-11 01:15:17
问题 A Finnish customer tells me that the correct (locale aware) sorting for Finnish is: a-z, å, ä, ö. But QString::localeAwareCompare() returns it as: a, ä, å, b-o, ö, p-z in Qt 4.4.2 on Windows Vista. #include <qapplication.h> #include <qlocale.h> #include <iostream> #include <tchar.h> int main( int argc, char* argv[] ) { QLocale::setDefault ( QLocale( QLocale::Finnish ) ); QApplication app( argc, argv ); QString s1 = "a"; QString s2 = "ä"; QString s3 = "å"; QString s4 = "b"; QString s5 = "o";

clear widget in a QGraphicsScene : crash

情到浓时终转凉″ 提交于 2019-12-11 01:06:16
问题 I have a QGraphicsScene with a QPushButton inside, and clearing this scene will crash my application. Is there a correct way to clear a scene with a QWidget ? The following code crashes when clicking on the button: #include <QApplication> #include <QGraphicsView> #include <QGraphicsScene> #include <QGraphicsProxyWidget> #include <QPushButton> int main(int argc, char *argv[]) { QApplication app(argc, argv); QGraphicsScene *scene = new QGraphicsScene(); QGraphicsView *view = new QGraphicsView()

Problems using HOGDescriptor

落花浮王杯 提交于 2019-12-11 00:42:52
问题 I'm fiddling with a bit of c++/opencv. I was looking some of the samples and haven't manage to compile/run peopledetect.cpp which uses HOGDescriptor . I've setup a basic Qt Console Application to test and narrow down the problem and got to this basic code: #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/objdetect/objdetect.hpp" #include <stdio.h> #include <string.h> #include <ctype.h> using namespace cv; using

Qt Artificial mouse clicks doesnt work properly

為{幸葍}努か 提交于 2019-12-10 22:32:39
问题 Small toy app can be found here: http://gist.github.com/517445 I am trying to send artificial mouse event to widget and I use QApplication::sendEvent for that, next I check ev.isAccepted() and it returns False, even worse! Widget I've sent event to doesnt handle it (it is calendar widged and no date is picked) and I am in doubt that it even receives it, because I can see how mouseEventPressed is fired up on parent widget. Qt Code: #include "calendar.h" Calendar::Calendar(QWidget *parent) :

How do I set my application version for Windows in Qt?

你。 提交于 2019-12-10 22:19:31
问题 When my application crashes, the Windows Event Viewer always reports my application version as "0.0.0.0". I can't figure how to set the application version in a way that the Windows Event Viewer recognizes. Changing it with QApplication::setApplicationVersion() doesn't seem to do it. Obviously there are better ways to debug a program than the Windows Crash Log, but in lieu of all of that, how would I go about setting this value so that Windows recognizes it? My IDE is Qt Creator. 回答1: You can

Unhandled Exception using glGenBuffer on Release mode only - QT

China☆狼群 提交于 2019-12-10 21:42:37
问题 I'm having some trouble while compiling my project on Windows 7 using Qt 4.8 on Release mode. Everything works fine on Debug, but on Release I get an Unhandled Exception: 0xC0000005: Access violation. I narrowed it down to the line where this happens, which is when I generate my Pixel Buffers. My first guess would be wrong DLLs loading, but I checked the executable with Dependency Walker and every DLL loaded is correct. Here goes some of my code: class CameraView : public QGLWidget, protected