[Kde-bindings] Qt, Qyoto buttons work intermediately

Arno Rehn arno at arnorehn.de
Tue Feb 16 11:54:00 UTC 2010

On Tuesday 16 February 2010 10:29:11 linuxoid.au at gmail.com wrote:
> > I need the exact code please. With code snippets alone I can't reproduce
> > what you did there.
> Please download the code from here:
> http://qt-giraff.svn.sourceforge.net/viewvc/qt-giraff/trunk/source/
> MainApplication - main window class
> startui - 1st stacked widget page
> basicvideo.cs - 2nd stacked widget page
> What I want to do is to take all these signals from StartVideoCodec() in
> MainApplication and corresponding SLOTS:
> 		private void StartVideoCodec() {
> 		    basicVideoPage = new QWidget();
> 			stackWidget.AddWidget(basicVideoPage);
> 			stackWidget.SetCurrentIndex(1);
> 			basicvideowin = new BasicVideoWindowUI();
> 			basicvideowin.BasicVideoUI(this, basicVideoPage);
> 			Connect(basicvideowin.txtSource, 
SIGNAL("textChanged(QString)"), this,
> SLOT("enableStart()")); // - this one Connect(basicvideowin.btnSource,
> SIGNAL("clicked()"), this, SLOT("GetSource()")); // - this one
> Connect(basicvideowin.btnDestination, SIGNAL("clicked()"), this,
> SLOT("GetDestination()")); // - this one Connect(basicvideowin.btnStart,
> SIGNAL("clicked()"), this, SLOT("StartCodec()")); // - this one
> Connect(basicvideowin.btnQuit, SIGNAL("clicked()"), qApp, SLOT("quit()"));
> // - this one }
> 		[Q_SLOT]
> 		private void GetSource() {
> 			string dir = QFileDialog.GetExistingDirectory(this);
> 			basicvideowin.txtSource.Text = dir;
> 		}
> 		[Q_SLOT]
> 		private void GetDestination() {
> 			string dir = QFileDialog.GetExistingDirectory(this);
> 			basicvideowin.txtDestination.Text = dir;
> 		}
> 		[Q_SLOT]
> 		private void StartCodec() {
> 				string param = "kwrite " + 
> 				QProcess play = new QProcess(this);
> 				play.Start(param);
> 		}
It doesn't work because you have this line on top of your 
BasicVideoUI(QMainWindow mainwin, QWidget page) method:

mainwin = new QMainWindow();

Obviously this breaks the rest.
That's why I would like to have small test cases, if possible. I don't want to 
dig through hundreds of lines of irrelevant source code just to find out that 
the 'bug' is really just PEBCAK. Sorry, but I don't really have the time for 
Another tip for the design: Currently you have only one custom subclass and a 
lot of classes that operate on it. Design-wise it's better to create more 
QWidget subclasses for you different stack widget pages. You can then have 
signals and slots for each stack widget page. That doesn't clutter your 
MainWindow class and its meta object.

And a last tip: look at what is printed in the terminal. That's often quite 
helpful. In this case it printed:
Object::connect: No such slot QMainWindow::enableStart()
Object::connect: No such slot QMainWindow::GetSource()
Object::connect: No such slot QMainWindow::GetDestination()
Object::connect: No such slot QMainWindow::StartCodec()
Which made it obvious that something was wrong with the class reference 
contained in the "mainwin" var.

So, please: next time something doesn't work and you suspect it to be a bug, 
please try to make a minimal app which exhibits the behaviour. That makes life 
easier for all of us ;)

Arno Rehn
arno at arnorehn.de

More information about the Kde-bindings mailing list