Qlabel is invisible...why?

Frank linux at suffolkconnection.com
Thu Mar 7 23:48:04 UTC 2002


Hello all.

Sandy,  I took some of your advice for now and used QDialog instead of 
QWidget.

I've narrowed down the issue to this:
Referring to function of learnprogramming.cpp:
MyInfoWindow::MyInfoWindow() : QDialog(0,0,TRUE)

This works fine but It isn't what I want.  This makes the QDialog a "Modal" 
dialog.  Because it is modal, the KProcess call using Commandlinez is not 
executed until the QDialog is closed.

To fix that I made the QDialog "Modeless" by simply changing TRUE to FALSE
e.g.: --->MyInfoWindow::MyInfoWindow() : QDialog(0,0,FALSE)

Now that it is "Modeless" the Qdialog reacts correctly but the text that was 
embedded in it through QLabel, is no long showing.  So I am back to the 
original odd problem.

Is there more to changing QDIALOG to FALSE for making it Modeless?

In this syntax reference:
QDialog::QDialog ( QWidget * parent=0, const char * name=0, bool modal=FALSE, 
WFlags f=0 )
I don't understand "QWidget * parent=0" and "const char * name=0"  What 
should be there?
According to the book (0,0,TRUE) is fine but doesn't explain what the usage 
of 0,0 is for.
This Book is kind of weak now that I look at it more familiar.

I hope you can help.
Here is the updated 3 files.



/////////////////////////////////////////////
//      THIS IS THE learnprogramming.h HEADER FILE       
/////////////////////////////////////////////

#include <qapplication.h>
#include <qwidget.h>
#include <qfiledialog.h>
#include <qstring.h>
#include <qdir.h>
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qmessagebox.h>
#include <kprocess.h>
#include <stdlib.h>
#include <qlabel.h>
#include <qdialog.h>

class MyInfoWindow:public QDialog
{
public:
	MyInfoWindow();
private:
	QLabel *labeld;
};

class MyMainWindowFSD:public QWidget
{
Q_OBJECT
public:
	MyMainWindowFSD();
private:
	QPushButton *b1;
	QPushButton *b2;
	QPushButton *b3;
	QString RootDir;
	QFileDialog *fdialog;
	QString filez;
	QString Ufilez;
	QListBox *listbox;
	QMessageBox *quitbox;
	MyInfoWindow *infoz;
	KProcess CommandLinez;
public slots:
	void MyFileDialog();
	void QuitProgram();
	void UpLinkz();
};





////////////////////////////////////////
//   THIS IS THE learnprogramming.cpp FILE
////////////////////////////////////////

#include "learnprogramming.h"  //This headerfile isn't the problem so far

MyMainWindowFSD::MyMainWindowFSD()
{
		setGeometry(100,100,400,300);
		
		b1 = new QPushButton("Add File", this);
		b1->setGeometry(20,20,100,40);
		b1->setFont(QFont("Times",12,QFont::Bold));

		b2 = new QPushButton("Quit", this);
		b2->setGeometry(20,230,100,40);
		b2->setFont(QFont("Times",12,QFont::Bold));
		
		b3 = new QPushButton("Play", this);
		b3->setGeometry(20,80,100,40);
		b3->setFont(QFont("Times",12,QFont::Bold));
				
		listbox = new QListBox(this);
		listbox->setGeometry(150,20,230,250);
		
		connect(b1,SIGNAL(clicked()),this,SLOT(MyFileDialog()));
		connect(b2,SIGNAL(clicked()),this,SLOT(QuitProgram()));
		connect(b3,SIGNAL(clicked()),this,SLOT(UpLinkz()));
		
}

void MyMainWindowFSD::MyFileDialog()
{
		RootDir=QDir::homeDirPath();		
		filez=fdialog->getOpenFileName(RootDir, "*.wav");
			if(filez.isNull()==FALSE)
		{
			listbox->insertItem(filez);
			FileCounter++;
		}
}


void MyMainWindowFSD::QuitProgram()
{
	QMessageBox quitbox("Proceed with Quit?", "Do you really want to quit?",
	                        QMessageBox::Information,
													QMessageBox::Yes | QMessageBox::Default,
													QMessageBox::No | QMessageBox::Escape,
													0);
	switch (quitbox.exec())
	{
		case QMessageBox::Yes:
			exit(0);
			break;
		case QMessageBox::No:
			break;
	}
}


void MyMainWindowFSD::UpLinkz()
{
	infoz = new MyInfoWindow();
	
	for (i=FileCounter; i > -1; i--)
	{
	infoz->show();
	KProcess CommandLinez;
	CommandLinez.clearArguments();

	CommandLinez <<"playwave";
	Ufilez=listbox->text(i);

	CommandLinez << Ufilez;
	CommandLinez.start(KProcess::Block,KProcess::Stdin);
		
	listbox->removeItem(i);
	infoz->close();
	}
}

/////////////////////////////////
// This is the area in question//
/////////////////////////////////
MyInfoWindow::MyInfoWindow() : QDialog(0,0,TRUE)
{
    setCaption("Work In Progress");
		
		labeld= new QLabel(this);
		labeld->setGeometry(10,10,160,40);
		labeld->setText("Uplinking File(s)...");
		labeld->setFont(QFont("Times",12,QFont::Bold));
		labeld->setAlignment(AlignCenter);
}




//////////////////////////////////////////////
// THIS IS THE main.cpp FILE
//////////////////////////////////////////////

#include "learnprogramming.h"

int main( int argc, char ** argv )
{

		QApplication a( argc, argv );
		MyMainWindowFSD w;
		a.setMainWidget(&w);
		w.show();
		return a.exec();
}




More information about the KDevelop-devel mailing list