PDA

View Full Version : camera



Harini
16th December 2013, 12:28
Hello everyone :)
I'm trying to design a camera, getting lot of errors...here is my project in attachments...can anyone please help me in rectifying those errors???

wysota
17th December 2013, 09:06
I think you might get more answers if you tell us what the error is and show us the offending piece of code instead of posting your whole large project. People might not be willing to spend their time unpacking your project, building it and going through the compilation log.

Harini
17th December 2013, 13:34
actually got many errors so attaches the project...anyway here is my code


#ifndef _SPLASHSCREEN_H_
#define _SPLASHSCREEN_H_

#include <QPixmap>
#include <QWidget>
#include <QSplashScreen>

class SplashScreen : public QWidget
{
private:
QPixmap pix;
public:
SplashScreen(const QPixmap &pixmap );
void finish();
void repaint();
void showMessage(const QString &message,
int alignment =Qt::AlignLeft,
const QColor &color = Qt:: white);
};

#endif
#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QSplashScreen>
#include <QWidget>

#include "SplashScreen.h"

SplashScreen::SplashScreen(const QPixmap &pixmap ) :
QWidget(0, 0,WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop | WStyle_Tool),
pix( pixmap )
{
setBackgroundPixmap(pix);
resize( pix.size() );
QRect scr = QApplication::desktop()->geometry();
move( scr.center() - rect().center() );
show();
repaint();
}
void SplashScreen::repaint()
{
QWidget::repaint();
qApp->processEvents();
}
void SplashScreen::finish()
{
close();
}

void SplashScreen::showMessage(const QString &message,
int alignment =Qt::AlignLeft,
const QColor &color = Qt:: white);
{
QPixmap textPix = pix;
QPainter painter( &textPix, this );
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial", 30));
QRect r = rect();
r.setRect( r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20 );
painter.drawText( r, alignment, message );
setBackgroundPixmap( textPix );
repaint();
}

#ifndef MYDIALOG_H
#define MYDIALOG_H

#include <QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QComboBox>

class MyDialog : public QDialog
{
Q_OBJECT

public:
MyDialog(QWidget *parent=0,const char *name=0,bool modal=true,Qt::WindowFlags f=0);


QString getName();

private slots:
void slotHighlighted(int);
void slotSelected(int);

private:
QComboBox* lb1;
QString str;
};
#endif

#include <QMessageBox>
#include <QDir>
#include <QComboBox>
#include "mydialog.h"

MyDialog::MyDialog(QWidget *parent, const char *name, bool modal,Qt:: WindowFlags f=0)
:QDialog(parent,name,modal,f)
{
lb1 = new QComboBox(this);
lb1->setGeometry(10,10,200,70);

QDir dir;

dir.setCurrent( "./" );
dir.setNameFilter("*.jpg");
for(int i=0;i<(int)dir.count();i++)
lb1->insertItem(dir[i]);

connect(lb1,SIGNAL(selected(int)),this,SLOT(slotSe lected(int)));
connect(lb1,SIGNAL(highlighted(int)),this,SLOT(slo tHighlighted(int)));
}

QString MyDialog::getName()
{
return str;
}

void MyDialog::slotSelected(int index)
{
str = lb1->text(index);
accept();
}

void MyDialog::slotHighlighted(int index)
{
str = lb1->currentText();
}



#ifndef WEBCAM_H
#define WEBCAM_H


#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/select.h>

#include <QFileDialog>
#include <QPushButton>
#include <QPainter>
#include <QImage>
#include <QPixmap>
#include <QWidget>
#include <QDateTime>

#include <linux/videodev.h>
#include <linux/videodev2.h>

class WebCam : public QWidget
{
Q_OBJECT
public:
WebCam(const QWidget *parent=0, const char *name=0 );
// WebCam::
~WebCam();
QPushButton* Exit;
QTimer *capt;

int video_open(const char *devname);
int video_set_format(void);
int video_reqbufs(void);
int video_enable(int dev, int enable);
int fixup_jpeg1(unsigned char *input, int input_size, unsigned char *output);
void map_the_buffers();
void Queue_the_buffers();
void start_streaming();
int i,n;
protected:
void paintEvent( QPaintEvent *);
private slots:
void slotTimeout();
private:
void drawImage();
void changeBKImage();
QTime time;
QPixmap *pmBk;
QPixmap *pmPaint;
QImage CMOSImage;
QFileDialog *fd;


};

#endif // WEBCAM_H




#include <QtGui/QApplication>
#include <QWidget>
//#include <unistd.h>
#include "webcam.h"
#include "SplashScreen.h"
#include "mydialog.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
WebCam *usbcam = new WebCam;
// a.setWidget(usbcam);
usbcam->show();

int result = a.exec();
delete usbcam;
return result;
}

[CODE]#include <stdlib.h>

#include <QApplication>
#include <QWidget>
#include <QTimer>
#include <QPainter>
#include <QMatrix>
#include <QSplashScreen>
#include <QFileDialog>
#include <QPushButton>
#include <QImage>
#include <QPixmap>
#include <QDateTime>
#include <QAudioOutput>

#include "webcam.h"
#include "SplashScreen.h"
#include "mydialog.h"

#define VAL 0
#define VAL1 1
static unsigned char huffman_table[] = {
0xFF,0xC4,0x01,0xA2,0x00,0x00,0x01,0x05,0x01,0x01, 0x01,0x01,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x02,
0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x01, 0x00,0x03,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, 0x00,0x00,
0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,
.................................................. .........,0xF8,0xF9,0xFA};

struct v4l2_buffer buf;
unsigned int i,size,buf_size;
char filename[] = "quickcam-0000.jpg";
int dev, ret;
FILE *file;
void *mem;
unsigned char data[65000];
WebCam::WebCam(const QWidget *parent, const char *name)
: QWidget( parent, name )
{
setWindowTitle("Project : Qt/E USB Camera Image capture");
resize( QSize(320, 240).expandedTo(minimumSizeHint()) );
//ClearState( State_Polished );
video_open("/dev/video1")
QPixmap pixmap("logo.png");
// QSplashScreen* splash = new SplashScreen(pixmap);
QSplashScreen splash(pixmap);
splash.showMessage("Initialize...", 0,"Red");
qApp->processEvents();
sleep(3);
splash.finish();
splash.deleteLater();
video_set_format();
video_reqbufs();
map_the_buffers();
Queue_the_buffers();
video_enable(dev,1);
start_streaming();
changeBKImage();

pmPaint = new QPixmap(320, 240);

capt = new QTimer( this );
capt->start(1);
connect( capt, SIGNAL(timeout()), SLOT(slotTimeout()) );
}

WebCam::~WebCam()
{

qWarning("USB-WebCamera exit!! \n");
capt->stop();
video_enable(dev,0);
munmap(mem,buf.length);
close(dev);
}
void WebCam::start_streaming()
{
memset(&buf, 0, sizeof buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev, VIDIOC_DQBUF, &buf);
if (ret < 0)
{
printf("Unable to dequeue buffer (%d).\n", errno);
close(dev);
}

// Save the image.
sprintf(filename, "/root/quickcam-%03u.jpg", VAL1);
file = fopen(filename, "wb");
if (file != NULL)
{
unsigned char *input;
int input_size;
unsigned char *output;
// int output_data;
input = (unsigned char*)mem;
input_size=buf.bytesused;
int has_dht = 0;
output = data;
unsigned char hdr[4];
int o_count=0;
int r_count=0;
int size;
output[o_count++] = 0xFF;
output[o_count++] = 0xD8;
r_count += 2;
while(!has_dht)
{
memcpy(hdr, input+r_count, 4);
r_count += 4;
if(hdr[1]==0xC4) has_dht = 1;
else if(hdr[1]==0xDA) break;

// skip to the next marker
size = (hdr[2]<<8) + hdr[3];
memcpy(output+o_count, hdr, 4);
o_count += 4;
memcpy(output+o_count, input+r_count, size-2);
r_count += (size-2);
o_count += (size-2);
}

if(!has_dht)
{
memcpy(output+o_count, huffman_table, sizeof(huffman_table));
o_count += sizeof(huffman_table);
memcpy(output+o_count, hdr, 4);
o_count += 4;
}
// Process the remaining data in one go
memcpy(output+o_count, input+r_count, input_size-r_count);
o_count += (input_size-r_count);
r_count += (input_size-r_count);
input=NULL;
output=NULL;
fwrite(data,o_count,1,file);
fclose(file);
}
// Requeue the buffer.
ret = ioctl(dev, VIDIOC_QBUF, &buf);
if (ret < 0)
{
printf("Unable to requeue buffer (%d).\n", errno);
close(dev);
}

fflush(stdout);
}
void WebCam::Queue_the_buffers()
{
memset(&buf, 0, sizeof buf);
buf.index = VAL;
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev, VIDIOC_QBUF, &buf);
if (ret < 0)
{
printf("Unable to queue buffer (%d).\n", errno);
close(dev);
}
}
void WebCam::map_the_buffers()
{
memset(&buf, 0, sizeof buf);
buf.index = VAL;
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev, VIDIOC_QUERYBUF, &buf);
if (ret < 0)
{
printf("Unable to query buffer %u (%d).\n", VAL, errno);
close(dev);
}
printf("length: %u offset: %u\n", buf.length, buf.m.offset);
mem = mmap(0, buf.length, PROT_READ, MAP_SHARED, dev, buf.m.offset);
if (mem == MAP_FAILED)
{
printf("Unable to map buffer %u (%d)\n", VAL, errno);
close(dev);
}
printf("Buffer %u mapped at address %p\n", VAL, mem);
}
int WebCam::video_set_format()
{
struct v4l2_format fmt;
memset(&fmt, 0, sizeof fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = 320;
fmt.fmt.pix.height = 240;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
fmt.fmt.pix.field = V4L2_FIELD_ANY;

ret = ioctl(dev, VIDIOC_S_FMT, &fmt);
if (ret < 0) {
printf("Unable to set format: %d.\n", errno);
return ret;
}

printf("Video format set: width: %u height: %u buffer size: %u\n",
fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.sizeimage);

return 0;
}
int WebCam::video_reqbufs()
{
struct v4l2_requestbuffers rb;
memset(&rb, 0, sizeof rb);
rb.count = 16;
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
rb.memory = V4L2_MEMORY_MMAP;

ret = ioctl(dev, VIDIOC_REQBUFS, &rb);
if (ret < 0)
{
printf("Unable to allocate buffers: %d.\n", errno);
return ret;
}

printf("%u buffers allocated.\n", rb.count);
return 0;
}
int WebCam::video_enable(int dev, int enable)
{
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = ioctl(dev, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type);
if (ret < 0) {
printf("Unable to %s capture: %d.\n", enable ? "start" : "stop", errno);
return ret;
}

return 0;
}
int WebCam::video_open(const char *devname)
{
struct v4l2_capability cap;

dev = open(devname, O_RDWR);
if (dev < 0) {
printf("Error opening device %s: %d.\n", devname, errno);
exit(1);
}

memset(&cap, 0, sizeof cap);
ret = ioctl(dev, VIDIOC_QUERYCAP, &cap);
if (ret < 0) {
printf("Error opening device %s: unable to query device.\n",devname);
close(dev);
return ret;
}
if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
printf("Error opening device %s: video capture not supported.\n",
devname);
close(dev);
return -EINVAL;
}

printf("Device %s opened: %s.\n", devname, cap.card);
return dev;
}
void WebCam::slotTimeout()
{
start_streaming();
changepmBKImage();
repaint(false);
}

void WebCam::paintEvent( QPaintEvent * )
{
QPainter painter(this);
drawImage();
painter.drawPixmap(0, 0, *pmPaint);
}
void WebCam::changepmBKImage()
{
QString strFilename;
strFilename.sprintf("/root/quickcam-%03d.jpg", VAL1);
if (!pmBk.load(strFilename)) {
qDebug("QPixmap load error\n");
}
}
void WebCam::drawImage()
{
QMatrix matrix;
QPainter painter;
QString strTime;
matrix.scale(-1.0,1.0);
pmBk=pmBk.xForm(matrix);
pmPaint->resize(width(), height());
painter.begin(pmPaint, this);
painter.drawPixmap(QPoint(0, 0),pmBk);
painter.end();
}

wysota
17th December 2013, 14:14
Cool, but what is the error?

Harini
18th December 2013, 06:57
not only one....am getting many many errors,not getting cleared....Here is the screen shot9864
Cool, but what is the error?

Added after 14 minutes:

/home/stesalit/Desktop/cam/webcam.cpp:14: error: QAudioOutput: No such file or directory
/home/stesalit/Desktop/cam/webcam.cpp:70: error: no matching function for call to ‘QWidget::QWidget(const QWidget*&, const char*&)’
/home/stesalit/Desktop/cam/webcam.cpp:90: error: no matching function for call to ‘QSplashScreen::finish()’

most repeating error
/home/stesalit/Desktop/cam/webcam.cpp:115: error: no matching function for call to ‘WebCam::close(int&)’


/home/stesalit/Desktop/cam/webcam.cpp:139: error: conflicting declaration ‘int output’
/home/stesalit/Desktop/cam/webcam.cpp:138: error: ‘output’ has a previous declaration as ‘unsigned char* output’
/home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
/home/stesalit/Desktop/cam/webcam.cpp:141: error: within this context
/home/stesalit/Desktop/cam/webcam.cpp:141: error: cannot convert ‘QWidgetData*’ to ‘unsigned char*’ in assignment
/home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
/home/stesalit/Desktop/cam/webcam.cpp:185: error: within this context
/home/stesalit/Desktop/cam/webcam.cpp:328: error: ‘changepmBKImage’ was not declared in this scope
/home/stesalit/Desktop/cam/webcam.cpp:329: error: no matching function for call to ‘WebCam::repaint(bool)’

wysota
18th December 2013, 08:00
Add QT += multimedia to your project file and rerun qmake. Remember, only the first error is significant, the rest may be merely a result of the compiler trying to recover from the first error.

Harini
18th December 2013, 09:05
Add QT += multimedia to your project file and rerun qmake. Remember, only the first error is significant, the rest may be merely a result of the compiler trying to recover from the first error. where to add QT += multimedia in the project?? :(

wysota
18th December 2013, 09:07
where to add QT += multimedia in the project?? :(

In the project file. You know... the one qmake uses.

Harini
18th December 2013, 09:35
but still facing the same error

In the project file. You know... the one qmake uses.

wysota
18th December 2013, 10:56
but still facing the same error

Please paste your project file here, marking where you added the line. Also please state where you have the QAudioOutput file in your filesystem.

Harini
19th December 2013, 07:37
Please paste your project file here, marking where you added the line. Also please state where you have the QAudioOutput file in your filesystem.

Actually I'm new to qt si I dont know where to add that but tried some how :P

#include <QtGui/QApplication>
#include <QWidget>
//#include <unistd.h>
#include "webcam.h"
#include "SplashScreen.h"
#include "mydialog.h"

QT +=multimedia

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
WebCam *usbcam = new WebCam;
// a.setWidget(usbcam);
usbcam->show();

int result = a.exec();
delete usbcam;
return result;
}

Added after 5 minutes:

Here
// Save the image.
sprintf(filename, "/root/quickcam-%03u.jpg", VAL1);
file = fopen(filename, "wb");
if (file != NULL)
{
unsigned char *input;
int input_size;
unsigned char *output;
// int output_data;
input = (unsigned char*)mem;
input_size=buf.bytesused;
int has_dht = 0;
output = data;
unsigned char hdr[4];
int o_count=0;
int r_count=0;
int size;
output[o_count++] = 0xFF;
output[o_count++] = 0xD8;
r_count += 2;

while(!has_dht)
{
memcpy(hdr, input+r_count, 4);
r_count += 4;

if(hdr[1]==0xC4) has_dht = 1;
else if(hdr[1]==0xDA) break;

// skip to the next marker
size = (hdr[2]<<8) + hdr[3];
memcpy(output+o_count, hdr, 4);
o_count += 4;

memcpy(output+o_count, input+r_count, size-2);

r_count += (size-2);
o_count += (size-2);
}

if(!has_dht)
{
memcpy(output+o_count, huffman_table, sizeof(huffman_table));
o_count += sizeof(huffman_table);
memcpy(output+o_count, hdr, 4);
o_count += 4;
}
// Process the remaining data in one go
memcpy(output+o_count, input+r_count, input_size-r_count);
o_count += (input_size-r_count);
r_count += (input_size-r_count);

input=NULL;
output=NULL;
fwrite(data,o_count,1,file);
fclose(file);
}

wysota
19th December 2013, 09:07
"Project file" is the one with "pro" extension.

Harini
19th December 2013, 09:59
can I add in the beginning of the file??

wysota
19th December 2013, 10:03
can I add in the beginning of the file??

Why don't you try and see for yourself?

Harini
19th December 2013, 10:57
actually I'm trying for this code from last 4days.This is the last day for me to go back to my sir...so asking for help

Added after 45 minutes:

I have done like this....is this the correct way??

<variable>activebuildconfiguration</variable>
<value type="QT +=multimedia">Debug</value>
</data>
<data>

wysota
19th December 2013, 18:54
I have done like this....is this the correct way??

No, this file does not have a "pro" extension. I suggest you spend one or two hours reading Qt documentation instead of blindly trying things for the next four days.

Harini
21st December 2013, 08:01
No, this file does not have a "pro" extension. I suggest you spend one or two hours reading Qt documentation instead of blindly trying things for the next four days.

I have included here in the pro file...still getting the errors.

QT += multimedia
TARGET = cam
TEMPLATE = app
SOURCES += main.cpp \
webcam.cpp \
SplashScreen.cpp \
mydialog.cpp
HEADERS += webcam.h \
SplashScreen.h \
mydialog.h
FORMS +=
OTHER_FILES += logo.png

Added after 47 minutes:

what does these mean and how to rectify these??

error: within this context
error: expected primary-expression before ‘int’

wysota
21st December 2013, 08:52
This is not the first error. Post the first error.

Harini
21st December 2013, 10:30
every thing got cleared finally left with these....

/home/stesalit/Desktop/cam/webcam.cpp:90: error: expected primary-expression before ‘)’ token
/home/stesalit/Desktop/cam/../../qtsdk-2009.05/qt/include/QtGui/qwidget.h:783: error: ‘QWidgetData* QWidget::data’ is private
/home/stesalit/Desktop/cam/webcam.cpp:142: error: within this context
/home/stesalit/Desktop/cam/webcam.cpp:142: error: cannot convert ‘QWidgetData*’ to ‘unsigned char*’ in assignment
/home/stesalit/Desktop/cam/webcam.cpp:348: error: request for member ‘load’ in ‘((WebCam*)this)->WebCam::pmBk’, which is of non-class type ‘QPixmap*’
/home/stesalit/Desktop/cam/webcam.cpp:360: error: request for member ‘xForm’ in ‘((WebCam*)this)->WebCam::pmBk’, which is of non-class type ‘QPixmap*’
/home/stesalit/Desktop/cam/webcam.cpp:361: error: ‘class QPixmap’ has no member named ‘resize’
/home/stesalit/Desktop/cam/webcam.cpp:364: error: expected primary-expression before ‘*’ token
/home/stesalit/Desktop/cam/webcam.cpp:366: error: expected primary-expression before ‘*’ token

wysota
21st December 2013, 14:01
You have a syntax error in webcam.cpp line #89 or #90.

Harini
23rd December 2013, 06:46
/home/stesalit/Desktop/cam/webcam.cpp:186: error: within this context ---> what does this mean??

left with only these

/home/stesalit/Desktop/cam/webcam.cpp:348: error: request for member ‘load’ in ‘((WebCam*)this)->WebCam::pmBk’, which is of non-class type ‘QPixmap*’


/home/stesalit/Desktop/cam/webcam.cpp:364: error: expected primary-expression before ‘*’ token


/home/stesalit/Desktop/cam/webcam.cpp:361: error: ‘class QPixmap’ has no member named ‘resize’

Here, in the above error I'm not getting what to use in the place of "resize" I searched the entire doc but i dint found the size option so, what to use here??



Any one please please help me in rectifying these errors....

wysota
23rd December 2013, 09:47
/home/stesalit/Desktop/cam/webcam.cpp:186: error: within this context ---> what does this mean??
This means the previous error happened because of this line. As I said (and I won't repeat myself again) always look on the first error message.


left with only these

/home/stesalit/Desktop/cam/webcam.cpp:348: error: request for member ‘load’ in ‘((WebCam*)this)->WebCam::pmBk’, which is of non-class type ‘QPixmap*’


/home/stesalit/Desktop/cam/webcam.cpp:364: error: expected primary-expression before ‘*’ token


/home/stesalit/Desktop/cam/webcam.cpp:361: error: ‘class QPixmap’ has no member named ‘resize’
I think these messages are pretty much self-explanatory.

Harini
23rd December 2013, 10:06
done !! fynally ,left with this... getting :364: error: expected primary-expression before ‘*’ token here. painter.drawPixmap(QPixmap *pmBk,this); in the below code. please help me


void WebCam::drawImage()
{
QMatrix matrix;
QPainter painter(this);
QString strTime;

matrix.scale(-1.0,1.0);
// pmBk=pmBk.xForm(matrix);
// pmPaint->resize(width(),height());
resize(width(),height());
// pmPaint->resize( QSize(width(),height()).expandedTo(minimumSizeHint ()));
//pmPaint->rect(width(), height());
// painter.begin(QPaintDevice* pmPaint, this);
// painter.begin(*pmBk);
painter.begin(this);
// painter.drawPixmap(QPointF(0,0), QPixmap *pmBk, this);
painter.drawPixmap(QPixmap *pmBk,this);
// painter.drawPixmap(QPointF(0,0), &pmBk,this);
painter.begin(this);
painter.end();

wysota
23rd December 2013, 10:09
The offending line is not a proper C++ syntax. It should probably be drawPixmap(pmBk, this) or something like that.

Harini
23rd December 2013, 10:34
The offending line is not a proper C++ syntax. It should probably be drawPixmap(pmBk, this) or something like that.


when i use drawPixmap(pmBk, this) getting warnings and this error
error: no matching function for call to ‘QPainter::drawPixmap(QPixmap*&, WebCam* const)’

wysota
23rd December 2013, 10:35
Great. Now go and fix your code.

Harini
23rd December 2013, 10:38
Great. Now go and fix your code.

sorry, I dint get u


can u please give me the line with which I can replace??

wysota
23rd December 2013, 10:47
How should I know that? It is your code, not mine. You are the only person who knows what your intentions were when you were writting this non-working code.

Harini
23rd December 2013, 10:52
I replaced with this line painter.drawPixmap(this,QPixmap *pmBk,this ); but getting the same error error: expected primary-expression before ‘*’ token

wysota
23rd December 2013, 11:37
This is again invalid C++ code.

Maybe you should learn C++ first before trying to use it?

Harini
30th December 2013, 08:02
god diying with this :( tried a lot :(
again getting errors here...

#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QSplashScreen>
#include <QWidget>

#include "SplashScreen.h"

SplashScreen::SplashScreen(const QPixmap &pixmap,Qt::WindowFlags ) :
QWidget(pixmap , 0,Qt::FramelessWindowHint,
Qt::WindowStaysOnTopHint,
Qt::Tool)
//Qt::WStyle_Customize ,Qt:: WStyle_NoBorder ,Qt:: WStyle_StaysOnTop ,Qt:: WStyle_Tool)

{
QPixmap pix;
pix.load("image.jpg");
//setBackgroundPixmap(pix);

resize( pix.size() );

QRect scr = QApplication::desktop()->geometry();
move( scr.center() - rect().center() );
show();
repaint();
}

void SplashScreen::repaint()
{
QWidget::repaint();
qApp->processEvents();
}

void SplashScreen::finish()
{
close();
}

void SplashScreen::showMessage(const QString &message,
int alignment =Qt::AlignLeft,
const QColor &color = Qt:: white)

{
QPixmap textPix = pix;
QPainter painter( &textPix, this );
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial", 30));
QRect r = rect();
r.setRect( r.x() + 10, r.y() + 10, r.width() - 20, r.height() - 20 );
painter.drawText( r, alignment, message );
// setBackgroundPixmap( textPix );
painter.background(textPix);
repaint();
}



errors

/home/stesalit/Desktop/cam/SplashScreen.cpp:41: error: default argument given for parameter 2 of ‘void SplashScreen::showMessage(const QString&, int, const QColor&)’

/home/stesalit/Desktop/cam/SplashScreen.h:24: error: after previous specification in ‘void SplashScreen::showMessage(const QString&, int, const QColor&)’

/home/stesalit/Desktop/cam/SplashScreen.cpp:41: error: default argument given for parameter 3 of ‘void SplashScreen::showMessage(const QString&, int, const QColor&)’

/home/stesalit/Desktop/cam/SplashScreen.h:24: error: after previous specification in ‘void SplashScreen::showMessage(const QString&, int, const QColor&)’

/home/stesalit/Desktop/cam/SplashScreen.cpp:45: error: no matching function for call to ‘QPainter::QPainter(QPixmap*, SplashScreen* const)’

/home/stesalit/Desktop/cam/SplashScreen.cpp:52: error: no matching function for call to ‘QPainter::background(QPixmap&)’

wysota
30th December 2013, 08:51
The error is self-explanatory, it's still a problem with C++ syntax. Don't blindly copy code but rather write your own (which you understand) using correct C++ syntax.

Harini
31st December 2013, 13:50
#include <QMessageBox>
#include <QDir>
#include <QList>
#include <QComboBox>
#include "mydialog.h"

//MyDialog::MyDialog(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WindowFlags f= 0 )
//:QDialog(parent,name,modal,f)

MyDialog::MyDialog(QWidget* parent )
:QDialog(parent)

{
lb1 = new QComboBox(this);
lb1->setGeometry(10,10,200,70);

QDir dir;

dir.setCurrent( "./" );
//dir.setNameFilter("*.jpg");
dir.setNameFilters(QStringList()<<"*.jpg");
for(int i=0;i<(int)dir.count();i++)
lb1->insertItem(dir[i]);

connect(lb1,SIGNAL(selected(int)),this,SLOT(slotSe lected(int)));
connect(lb1,SIGNAL(highlighted(int)),this,SLOT(slo tHighlighted(int)));
}

QString MyDialog::getName()
{
return str;
}

void MyDialog::slotSelected(int index)
{
str = lb1->itemText(index);
accept();
}

void MyDialog::slotHighlighted(int index)
{
str = lb1->currentText();
}



error

/home/stesalit/Desktop/cam/mydialog.cpp:23: error: no matching function for call to ‘QComboBox::insertItem(QString)’


syntax error
tis is the line
void QComboBox::insertItem ( int index, const QString & text, const QVariant & userData = QVariant() )


and i tried a lot to implement this but still getting the error

with which line i can replace this ???

wysota
31st December 2013, 15:07
This forum is not a compiler. You have a compiler on your own machine. The compiler tells you there is not "insertItem" method that takes a string in QComboBox so don't use it.There is a insertItem method taking two arguments -- an index and a string. There is also an addItem() method that takes a single string. I really don't see the intent behind posting every syntax error you get to this forum. If you get a syntax error because you are using methods which don't exist then correct your code to use existing methods.

Harini
2nd January 2014, 12:41
which class supports QCamera properties in Qt 4.7