qt,user-interface,adc , Updating ac value for Qtimer

Updating ac value for Qtimer


Tag: qt,user-interface,adc

I am using qt tool for mini2440. I make a gui for i2c adc having starti2c and stopi2c. All things are working well: it reads value of signal when starti2c button press, but I want this value to be updated. I know that Qtimer can be used, but how can I do it? Here is the code:

# include <termio.h>
# include <time.h>
# include <string.h>
# include <sys/time.h>

HelloForm::HelloForm(QWidget* parent, const char* name, WFlags fl):

HelloBaseForm(parent, name, fl)







//*********************Code for getting i2c**************************// 
  char HelloForm::geti2c()

  char buf[100];                              
  char buff[100];     
  char valuee;

  int m1;   

  char con_buff[10];

  int fd=open("/dev/i2c/0",O_RDWR);

  if (fd<0)

   Message->setText(" NOT ABLE TO OPEN THE DRIVER ");




  Message->setText(" I2C IS WORKING ");


    int  io,wbyte,rbyte,i;

   //********i2cdetect and read************







Message->setText(" ");

 Message->setText("error ioctl");




                   // write all three control word to arm 



Message->setText("error write");








void HelloForm::starti2c()




float adc_val=0;





void HelloForm::stopi2c()

   ADC->setText(" ");


Hopefully this will get you started - it creates a timer which times out every 1000 milli seconds. The timer's timeout signal is connected to the same slot that your PushButton1 is connected to - starti2c.

QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(starti2c()));

That code should be placed below where you have your 2 connection statements.


connecting signals and slots with different relations

First of all I'd say I'm a noob to GUI programming. I use Qt 5.4. I came up with this code while watching voidRealms videos. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),ui->progressBar,SLOT(setValue(int))); Obviously this connects slider movement with progressbar fill. This actually works like progressbarfill <- slidermovement. How can I make into a different relation? Like...

QWidget.paintevent() vs QLabel.setPixmap()

I am trying to grab a widget and show it in another widget. Which one is less expensive? 1- using QWidget.paintevent() void MonitoringWidget::paintEvent(QPaintEvent *event) { if (m_mirrorWidget){ QPixmap mirrorPix = m_mirrorWidget->grab(); QPainter p(this); // p.drawPixmap(this->rect(),mirrorPix,mirrorPix.rect()); p.drawPixmap(ui->mirrorFrame->geometry(),mirrorPix,mirrorPix.rect()); update(); } return; } 2- QLabel.setPixmap()? QLabel mirrorLabel; QPixmap mirrorPix = m_mirrorWidget->grab(); mirrorLabel.setPixmap(mirrorPix )...

close sub-window without closing main window PyGTK in python

I am creating a gui in python with PyGtk and I would like to create a sub-window that branches off from my main window but unlike a dialog the user will be able to interact with the main window without having to close the sub-window. The following code was demonstrated...

Updating UI From a background thread on iOS

On iOS, its well documented that the UI should never be updated from a background thread. Rather the main thread should be the sole interface to update the UI. My Question is why? Is it because UIControls are not thread safe and hence there is always the possibility of main...

How to set User Agent in QtWebEngine QML application

NOTE: I was able to do that on QtWebKit QML using the QtWebView extension. Here I am interested in using QtWebEngine. My simple test application import QtQuick 2.1 import QtQuick.Controls 1.1 import QtWebEngine 1.0 ApplicationWindow { width: 800 height: 600 color: "lightgray" visible: true WebEngineView { id: webview url:...

Customizing QDateEdit style

How can i get the appearance of QDateEdit as shown on the image? I tried changing the stylesheet, but I dont know how to achieve the spacing between the button and the edit, nor how can I change the down arrow button....

Return const reference to local variable correctly

Additionally to the answers 1, 2, 3 and GotW88, assume the following methods QString createString() { return QString("foobar"); } const QString& getString() { return createString(); } This will yield the famous "warning C4172: returning address of local variable or temporary" with VS2013. Now if i changed the second method to...

How to differentiate a QNetworkReply is aborted or not?

I have the following code: connect(&netMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(loadFinished(QNetworkReply*)), Qt::UniqueConnection); reply = netMgr.get(qheader); How could I tell whether the loadFinished(); slot is triggered by calling reply->abort() or not?...

pyqt gui locked when calling cython function from QThread.run

In PyQt4 I want to execute code with no lock gui. I use QThread and emit signal for gui update. But if i call cython function in QThread.run gui will be locked. class Runner(QtCore.QThread): iter = QtCore.pyqtSignal(int) def __init__(self): QtCore.QThread.__init__(self) def do_something(self): beg = time.time() s = 0.0 while time.time()...

QT Combo Box of Line Pattern

i want to make a line pattern combo box in Qt same as it is shown in the picture , please tell me is it possible to make a combo box in Qt like shown in the picture. Any help would be appreciated Regards ...

Copy text and placeholders, variables to the clipboard

In my application I want generate random numbers or strings with a text in front of it. It is important for me that the text won't appear in my window, but instead gets copied to the clipboard. int randomnumber = rand() % 46 + 1; QClipboard *cb = QApplication::clipboard(); cb->setText("Just...

How to convert excel data to json at frontend side

I want to convert some excel data to JSON. Plan is to get my excel file from D drive, read data and make some UI for this. Can any one please help me out? Data is like this :- country year 1 2 3 4 Netherlands 1970 3603 4330 5080...

C++ & Qt: Random string from an array area

In my small Qt application, I want to pick a random string out of an array after I clicked on a button. I've read many threads but nothing works for me. So in my slot there's an array with several strings in it. I also implemented <string>, <time.h> and srand....

How can I have an animated system tray icon in PyQt4?

I am trying to create an animated systray icon for a pyqt4 app but am having trouble finding any examples in python. This is the closest I can find but it's in C++ and I don't know how to translate it over: Is there a way to have (animated)GIF image...

Is there a way to prevent Qt slider dragging beyond a value?

I have implemented the interface where the user is drawing a frame and then moving to next frame which will increment the slider value by 1. User can also increment or decrement the slider value. But, if user has drawn only upto frame 20 then user should not be able...

QEvent ownership

I want to send both predefined and custom QEvent to a Qt application. Is the event required be allocated on the heap or can I just pass the pointer to a object on the stack? QKeyEvent stackevent(QEvent::KeyPress); QKeyEvent* heapevent = new QKeyEvent(QEvent::KeyPress); QEvent * event; event = &stackevent; //valid ??...

Updating ac value for Qtimer

I am using qt tool for mini2440. I make a gui for i2c adc having starti2c and stopi2c. All things are working well: it reads value of signal when starti2c button press, but I want this value to be updated. I know that Qtimer can be used, but how can...

How can I override the member of (->) operator of a base class

Background: I have Qt generated UI classes with no common ancestor. I am subclassing a class (say, "Door") that uses one of these UI classes, and the derived class ("OakDoor") will use a different UI class, although much of the UI elements will have the same name. Until now I...

How to keep GridBagLayout from changing the size of a button

In my FlashCardPanel class, I have a subpanel,LabelPanel, with a Grid Bag Layout. It consists of a constructor with an edit button, a button to "flip" the card, and the label to display the term/definition. My problem is that every time I click my "Flip" Button to display the definition...

Rotating a Label In Qt with Python

I'm somewhat new to Qt and was wondering how to rotate a Label that has a pixmap inside of it. I've tried somethings like this: def paintEvent (self, event): t = QtGui.QTransform() image = QtGui.QImage(_fromUtf8(":/icons/BOOM_OUT.png")) pixmap = QtGui.QPixmap.fromImage(image) self.label.setPixmap(pixmap) t.translate(400,300) t.rotate(45) p = QtGui.QPainter(self) p.setTransform(t) p.drawPixmap((-pixmap.width()/2),(-pixmap.height()/2), pixmap) p.end() I know...

How can I wrap text in QGraphicsItem?

1) How can I wrap text in a QGraphicsTextItem to fit a fixed rectangle, with width and height ? Right now I am experimenting with creating a text, getting its bounding rectangle, and resizing it to fit the box - but I can't get wrapping. class TTT: public QGraphicsTextItem {...

Open a file from user input in python 2.7

How would I open a file by asking for user input? After raw_input("PROMPT") requests filename.txt from the user, I get the error code: TypeError: coercing to Unicode: need string or buffer, file found which tells me I need to convert the user input to a string, or format it a...

Python MVC style GUI Temperature Converter

#The view (GuiTest.py) import tkinter import Controller class MyFrame(tkinter.Frame): def __init__(self, controller): tkinter.Frame.__init__(self) self.pack() self.controller = controller #Output Label self.outputLabel = tkinter.Label(self) self.outputLabel["text"] = ("") self.outputLabel.pack({"side":"right"}) #Entry Space self.entrySpace = tkinter.Entry(self) self.entrySpace["text"] = ("") self.entrySpace.pack({"side":"left"}) #two convert buttons self.convertButton=tkinter.Button(self) self.convertButton["text"]= "Fahrenheit to...

Change background color of viewcontroller but not top area with clock

I want to make my whole ViewController grey except I want the top area where it shows CARRIER and the current time to remain white. Is the only way just to stick a View that covers everything except that area, and set it to grey, or is there some way...

Id in database using qt

I am new to qt. I have created a table in sql, and what I'm trying to do is to give an id whenever user adds data. For the first thing inserted it will be 1, second 2 and so on. So how to check what number was the last...

Pro file directive: copy target to folder at build step

I have a TEMPLATE = subdirs project with 6 subprojects which build in specified order. I would like to copy the output file of project1 (it's target) to some folder. This folder is passed with LIBS += -L to project2 and project2 may use this file as a static library....

How to put an image on another image in python, using ImageTk?

I want to put an image in front of another one, then use this combined image as a button's background image in Tkinter. How can I do it? I am free to import Tkimage, Image. Clarify: I want to stick this on the center of this so that something like...

How to change Eclipse IDE GUI icons?

Elipse icons are ugly. Fact! I would like to replace the icons with more flat, monochromatic and minimalist icons, but I can't find documentation on how to change icons from Eclipse's user interface. How could I do this? It's needed to recompile eclipse?...

MessageBox won't work when handling WM_DESTROY event from DialogBox

While elaborating an answer for another question (by myself), I've come up with the idea of using a MessageBox to report the result of my dialog box. It is a WinAPI modal dialog box created with the DialogBox() function. However, I noticed that handling WM_DESTROY in the dialog's procedure function...

QGraphicsScene on a QMainWindow

Still new to Python so I'm trying to get a QGraphicsScene to be inside a a QMainWindow. Right now the way I have it coded is that two windows will appear but I only want one window to appear with the QGraphicsScene "inside" the QMainWindow. Here is my code: import...

What does QHeaderView::paintSection do such that all I do to the painter before or after is ignored

This question is further development of this post and is different, though may seem similar as this one. I am trying to reimplement QHeaderView::paintSection, so that the background returned from the model would be honored. I tried to do this void Header::paintSection(QPainter * painter, const QRect & rect, int logicalIndex)...

Form controls not showing

I'm making a console application that shows a form. I created the form from scratch. When I run the program, the form shows, but the controls I added don't show. My code: using System; using System.Windows.Forms; using System.Drawing; namespace form { public class main { public static void Main() {...

Must compile Opencv with Mingw in order to use in QT under Winodws?

I've visit these blogs https://zahidhasan.wordpress.com/2014/08/19/qt-5-3-1-64-bit-mingw-windows/ How to link opencv in QtCreator and use Qt library http://www.cnblogs.com/grandyang/p/4328896.html All of them are using Mingw to compile Opencv through Cmake. If I want to use Opencv in QT, is compiling with Mingw the only way? I have this question because I already compiled...

Change attribute value of an XML tag in Qt

I'm trying to change the language attribute of a .ts file in Qt using Qt itself. Here is the sample XML format. <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE TS> <TS language="es_ES" version="2.1"> ... </TS> I have tried different ways, but no luck. Here are the methods I used. FileIOError FileIO::changeLanguageOfTsFile( QString tsFileName,...

Align horizontalcenter in Column

Column documentation explains how to achieve this: However, I would like to achieve this: That is, all items inside the Column should be horizontally aligned to the center. anchors.horizontalCenter: parent.Center does not work. How can I obtain the desired result?...

Repeat state on mouse click QML

Within the code I have a State, a Transition and a RotationAnimation defined. After the property change takes place, i.e. after the rotation is set to 360, the onClicked handler is rendered mute and the animation will never be played again after subsequent MouseArea clicks. Here is my current code:...

How to avoid user to click outside popup Dialog window using Qt and Python?

I created a Dialog window using Qt Creator and Python. I would like that Window stays on the top of my Gui AND avoid users to click outside that Dialog Until this dialog was closed.

Qstring error. Saving from Textpool to string

I've been trying to make simple 'typing game' where program is checking if input = showcased word. I'm trying to use Qt GUI, so I've placed two text widgets, and "play" button. However, there is a problem with string (or QString). Error: no match for 'operator=' (operand types are 'QString'...

How to change the opacity of Qt MainWindow?

How to change the opacity of the Qt MainWindow by some values? My main window contains nothing but just somehow I need to change the opacity using keystrokes. It looks like this now. I tried to set using this->setWindowOpacity(0.5); didn't get anything opacity effect. ...

Unable to connect to mariadb database server with qt 4.8.5 and Ubuntu 12.04

I use the following code to connect to a MySQL server database. QSqlDatabase db_Server = QSqlDatabase::database("Test"); //find mysql driver db_Server = QSqlDatabase::addDatabase("QMYSQL","Test"); db_Server.setHostName("188.**.***.***"); db_Server.setPort(3306); db_Server.setDatabaseName("Test"); db_Server.setUserName("Test"); db_Server.setPassword("*********"); bool ret = db_Server.open(); if(ret) qDebug() << "Database open" else qDebug() << db_Server.lastError().text(); Lately they changed the server to mariadb and I assumed...

Using QSimpleXmlNodeModel and QTreeView

I've been looking at ways to populate a QTreeView with data from an XML file. The XML will be simple. I've come across QSimpleXmlNodeModel and have been trying to figure out if this is suitable for my needs, but can't find any examples of its use. Can someone point me...

Javafx Tableview dont show data of ObservableList

i have a Problem mit the Tableview in JavaFX. I know there are some other posts in the forum, but i checked them and tried to use the solutions, but nothing work for me ... I have 3 Classes. One Version class, the data model. The Class which populats the...

Update bindings to var properties in QML

If you take a look at this page it notes that bindings to var properties are not automatically updated when the object changes: Item { property var car: new Object({wheels: 4}) Text { text: "The car has " + car.wheels + " wheels"; } Component.onCompleted: { car.wheels = 6; }...

UISpec4J tests in Eclipse are not found

I am trying to run tests using the UISpec4J library, but Eclipse says it can not find them. I have tried restarting Eclipse, cleaning the project, etc. The class gives no errors and I have followed the examples given on the website. package com.health.gui; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test;...

Java - Enforce TextField Format - UX - 00:00:00;00

Please see below image of the UI of my current application Currently, I am enforcing Data Format of the text fields in the back end. If the RegEx does match (00:00:00;00), it will throw an error. My question is from a UX perspective, is it possible to make the input...

change QDir::rootPath() to program running path?

I have a Qt FTP server that selects C:/ as root path. I'm trying to change that to select the starting program location path. For example: If ftpserver.exe is located in H:/programs/ftpserver.exe, it must automatically set the ftp root path to H:/. Code: ui->lineEditRootPath->setText(settings.value("settings/rootpath", QDir::rootPath()).toString()); Code: void MainWindow::on_toolButtonBrowse_clicked() { QString...

How to add a gif image in the statusbar Qt [closed]

I'm pretty new to Qt and I was told that I can add a gif image to the status bar using the QMovie class. Can anyone tell how it can be done and is there any other way to do this too?

How to pass QString variable to QFile?

getData gets the chosen file from a QTreeView and displays it on label 'test', enables the 'Apply' button, which when clicked calls setTheme void OptionsDialog::getData(const QModelIndex &index) { QString selected = model2->filePath(index); ui->test->setText(selected); ui->pushButton_apply_theme->setEnabled(true); } void OptionsDialog::setTheme() { //char *file = selected->toLatin1().data(); //const std::string file = selected->toStdString(); QFile qss(selected); qss.open(QFile::ReadOnly);...