LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need help w/tutorial (https://www.linuxquestions.org/questions/programming-9/need-help-w-tutorial-179460/)

FreakboY 05-08-2004 08:28 PM

Need help w/tutorial
 
It sounds stupid... but i just can't get it...

all i want is to make a form with a button and a textbox
and when that button is press i will get a message box
that tells me the contents of the textbox.. as simple as that
but i can make it work!!! it is just to hard for me... so i was
wondering if any of you could send me the sources for this!??
i want to use Kdevelop 3.0 and QT just like this tutorial:
http://women.kde.org/articles/tutorials/kdevelop3/
i can't get it to work...

thanks for your time!




btw, if i install a lot of windows fonts on my system will it make it slow!??
just like windows!??

leonscape 05-08-2004 08:42 PM

Post what you've got coded, any compile time errors or warnings, etc...

Quote:

btw, if i install a lot of windows fonts on my system will it make it slow!??
just like windows!??
No. Just takes space. The list is cached (Once after each new font is intalled, not at boot ), and read when needed. Theres nothing too slow it down. ( Why windows slows down I don't know. ).

FreakboY 05-08-2004 08:48 PM

i don't have any code or anything... i want to learn from an example!!

leonscape 05-08-2004 08:54 PM

AH I see, well I know KDE better than pure Qt, would that be OKay?

FreakboY 05-08-2004 09:09 PM

ya!! I just want QT for UI and thats all i want to do my coding using Kdev....

FreakboY 05-08-2004 09:09 PM

you can email me to ferdna at hotmail dot com

leonscape 05-08-2004 09:23 PM

Well with KDE start a project with type C++ -> KDE -> Simple KDE Application. I called my app example. So theres only two files you need to edit.

example.h
Code:

#ifndef _EXAMPLE_H_
#define _EXAMPLE_H_

#include <kmainwindow.h>

class KLineEdit;

/// The main window class
class example : public KMainWindow
{
    Q_OBJECT
public:
    /// Default Constructor
    example();

    /// Default Destructor
    virtual ~example();
protected slots:
  /// Slot for activation of the button
  void slotButtonPressed();
private:
  /// The Line edit widget
  KLineEdit *m_pTexBox;
};

#endif // _EXAMPLE_H_

example.cpp
Code:

#include "example.h"

#include <qlabel.h>
#include <qlayout.h>

#include <kmainwindow.h>
#include <klocale.h>
#include <klineedit.h>
#include <kpushbutton.h>
#include <kdialog.h>
#include <kpassivepopup.h>

example::example()
    : KMainWindow( 0, "example" )
{
        /// A VBoxLayout orders things vertically
  QVBoxLayout *vl = new QVBoxLayout( this, 0, KDialog::spacingHint() );
      /// A HBoxLayout orders things horizontally
  QHBoxLayout *hl = new QHBoxLayout( vl );
  hl->addWidget( new QLabel( i18n( "Test Here:" ), this ) );
  m_pTexBox = new KLineEdit( this );
  hl->addWidget( m_pTexBox );
  KPushButton *button = new KPushButton( i18n( "Press Me" ), this );
  vl->addWidget( button );

  connect( button, SIGNAL( clicked() ), SLOT( slotButtonPressed() ) );
}

example::~example()
{
}

void example::slotButtonPressed()
{
  KPassivePopup::message( i18n( "The Text" ), m_pTexBox->text(), this );
}

#include "example.moc"

Thats it. The popup will probably be at the bottom of the screen somewhere. If you want more options look at subclassing KPassivePopup, or KDialogBase.

FreakboY 05-09-2004 04:30 AM

Thanks leonscape... but is not what i'm looking for....
i want to use QT as my GUI designer... your example
is real good it compiles with out any problems... i want
the same kind of example but using QT designer..

leonscape 05-09-2004 12:29 PM

I've not used the Qt Designer myself. So I can't help you with that. The best thing I can suggest is to follow the tutorial, and follow the examples, and simply change the form to what you want, and alter the code as appropriate.

Sorry.

FreakboY 05-09-2004 11:30 PM

is it a good choice to use QT Designer!??

leonscape 05-10-2004 05:30 PM

Depends I suppose. Most of my stuff doesn't require much flexability in the ui. ( i.e. I haven't got other people tidiying it up, and I'm not inserting it other programs, where styles might be diffrent. )

Using the designer can be helpful for trying out siffrent designs, or you just want something to be going on with that you'll change later. If your going to be adding more things as you go along, the Desginer can help a lot there. Just haven't had call to use it myself yet.


All times are GMT -5. The time now is 01:57 AM.