LinuxQuestions.org
Review your favorite Linux distribution.
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 09-20-2003, 06:25 AM   #1
lsropia
Member
 
Registered: Dec 2002
Distribution: RedHat
Posts: 30

Rep: Reputation: 15
Angry Qt programming


Hello,

I have a Qt project like this (with usual include files, most of the code has been stripped so that it is easy to understand):
============================================
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Formd w;
QFileDialog fd;
fd.setMode ( QFileDialog::ExistingFiles );

QString Folder, OutFile;
ifstream ifs;

w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT(quit()));
return a.exec();
}
============================================


============================================
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
//formd.cpp
void Formd::OnO1() {

}

void Formd::OnO2() {
}

void Formd::OnO3() {
}

void Formd::OnO4() {
}

void Formd::OnStart() {
/*
code to process large file
*/
switch (buttonGroupXage)
{
case 0: {
/*
code to process large file
*/

progressNow = ( xInfo.CurrentSeekPosition / ( xInfo.TotalSizeOfAllFiles / 100));
if (progressNow > progressOld) {
progressOld = progressNow;
progressBarCompletion->setProgress( progressOld );
UpdateWindow();
}

}
case 1: {
/*
code to process large file and update progress bar
*/

}
break;
case 2: {
/*
code to process large file and update progress bar
*/
}
break;
case 3: {
/*
code to process large file and update progress bar
*/
}
break;

}

void OnCancel()
{
close();
}

void Formd::UpdateWindow()
{
textLabelCompletion->repaint();
textLabelFolder->repaint();
lineEditFolder->repaint();

textLabelInFile->repaint();
comboBoxInFile->repaint();

buttonGroupExchange->repaint();
radioButtonO1->repaint();
radioButtonO2->repaint();
radioButtonO3->repaint();
radioButtonO4->repaint();

spinBoxYear->repaint();
textLabelYear->repaint();
lineEditMonth->repaint();

buttonGroupType->repaint();
radioButtonD->repaint();
radioButtonText->repaint();

pushButtonCancel->repaint();
pushButtonStart->repaint();
}

============================================
There is a widget created as Formd having combo boxes, radio buttons, push buttons, edit boxes, static boxes etc.

The project compiled properly and doing what it is supposed to large extent. On one of the push button, the the function OnStart() is attached (slot/ connection). This function is processing a large file, therefore, takes a while to execute. I have two problems with this:

1. While this function is running, I am unable to cancel this process by push button cancel, which is having the code to terminate the programme. No controls for that matter are responding to keyboard or mouse clicks.

2. When this widget is minimised or hidden by another window, the widget does not refresh/ repaint until whole of the file is processed. (
This so happens in many applications on Linux including openOffice etc.). UpdateWindow code was put in to let the window refresh/ repaint and respond to mouse clicks and key board but didnot do the required thing.

Please help.


Alex
 
Old 09-21-2003, 03:10 PM   #2
mhearn
LQ Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 57
You need to learn about multithreading. Run the CPU intensive code in another thread, and you'll be sorted. Just be careful, multithreading is a really good way to get difficult to find bugs.
 
Old 09-24-2003, 03:57 PM   #3
joki
LQ Newbie
 
Registered: Sep 2003
Location: stralsund/germany
Distribution: gentoo
Posts: 14

Rep: Reputation: 0
i don't have the QT reference by hand, but i can imagine about a command to let the system process the event-stack.

try to search through the reference i don't think its hiding too "deep"
 
  


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
which programming language is used to do tcp/ip programming?? gajaykrishnan Linux - Networking 9 12-21-2012 05:16 AM
im new to programming but..... boxerboy Programming 6 08-26-2005 06:17 AM
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM
C programming oranj Linux - Networking 1 12-07-2004 12:40 AM
Qt Programming... jinksys Programming 1 08-06-2003 04:33 AM

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

All times are GMT -5. The time now is 07:04 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