LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-23-2005, 03:13 AM   #1
kiranbud
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Rep: Reputation: 0
qt program


Hi

i want to create a program with qt, By clicking on a button Internet Browser has to be opened with particular website address. Can any body help me out.
 
Old 11-23-2005, 11:02 PM   #2
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
Code:
///////////FILE qt.h
#include <qapplication.h>
#include <qwidget.h>
#include <qprocess.h>
#include <qpushbutton.h>

class myWidget:public QWidget
{
    Q_OBJECT
    public:
        QPushButton *button;
        myWidget( QWidget *parent = 0, const char *name = 0);
        ~myWidget( );

    public slots:
        void buttonClicked( );
};
/////////////////FILE qt.cpp#include <qapplication.h>
#include <qwidget.h>
#include <qprocess.h>
#include <qpushbutton.h>
#include "qt.h"

myWidget::myWidget( QWidget *parent , const char *name )
            :QWidget( parent, name )
        {
            button = new QPushButton(  "CLICK", this, "HI" );
            connect( button, SIGNAL( clicked( ) ), this, SLOT(buttonClicked()) );
        }
myWidget::~myWidget( )
        {
        }

        void myWidget::buttonClicked( )
        {
            QProcess *proc = new QProcess( this );
            proc->addArgument( "firefox" );
            proc->addArgument( "http://www.google.com" );
            proc->start( );
        }
/////////////////////////FILE main.cpp
#include <qapplication.h>
#include "qt.h"

int main( int argc, char **argv )
{
    QApplication q(argc, argv);
    myWidget *wid = new myWidget( );
    wid->show( );
    q.setMainWidget( wid );
    q.exec( );
}
//////////////////////////////FILE test.pro
######################################################################
# Automatically generated by qmake (1.07a) Thu Nov 24 10:25:43 2005
######################################################################

TEMPLATE = app
INCLUDEPATH += .

# Input
HEADERS += qt.h
SOURCES += main.cpp qt.cpp

Last edited by gizmo_thunder; 11-23-2005 at 11:04 PM.
 
Old 11-24-2005, 01:21 AM   #3
kiranbud
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
code is working correctly but event is not firing
 
Old 11-24-2005, 01:30 AM   #4
kiranbud
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Thank you for ur coding

coding is working correctly but event is not firing.

so plz send the code for firing event(i.e while clicking button "firefox" should pop up.
 
Old 11-24-2005, 02:58 AM   #5
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
AFAIK the above code should work
i hope you are using linux and that firefox
is present in the $PATH.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sms program and database in linux web program in windows.. does not see each other.. keikun_naruchan Programming 0 07-06-2005 01:40 AM
Total recovery: Which program? ghost4linux, YaST2? Best drive imaging program? lagu2653 Linux - Software 1 06-20-2005 01:44 PM
Key bindings program (custom pasting, program execution, etc.) jrdioko Linux - Software 2 02-05-2005 09:09 PM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-14-2003 11:18 PM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration