Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, December 2007
QStatusBar inside normal QDialog


Message 1 in thread

hello i would like to add a status bar to a normal dialog to do any information relative to active widget in
the dialog (with statusTip, i prefer this to a tooltip) but i cant find how to do this in qt documentation, it
seems the status bar it is only used in qmainwindow, how can i add a statusbar to a normal dialog? i have
tried creating one and laying in the dialog but it does not display widgets statustip, any good idea on this?	

--
 [ signature omitted ] 

Message 2 in thread

QStatusBar inherits QWidget, so you can add it to layout

On Dec 3, 2007, at 4:30 PM, Linos wrote:

> hello i would like to add a status bar to a normal dialog to do any  
> information relative to active widget in
> the dialog (with statusTip, i prefer this to a tooltip) but i cant  
> find how to do this in qt documentation, it
> seems the status bar it is only used in qmainwindow, how can i add  
> a statusbar to a normal dialog? i have
> tried creating one and laying in the dialog but it does not display  
> widgets statustip, any good idea on this?	
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 3 in thread

Two questions asked... First for the statusBar.

Lay it out using normal layout..
Then in order to get the QActions statusText onto your status bar, add a
event( QEvent * e ) method to your dialog class and set the status bar
text when the event is a QStatusBarEvent

Now, if you prefer to do it via a tool tip, every QWidget derived class
has a method called setToolTip( text )... QT takes care of the rest :)

Here is some VERY simple test code.
class CStatusBarTestClass : public QWidget
{
public:
	CStatusBarTestClass( QWidget * parent = NULL ) :
		QWidget( parent )
	{
		QVBoxLayout * vl = new QVBoxLayout( this );
		vl->setMargin( 0 );
		vl->setSpacing( 2 );

		QMenuBar * menuBar = new QMenuBar;
		QMenu * file = menuBar->addMenu( "File" );
		QAction * open = file->addAction( "Open" );
		open->setStatusTip( "Open" );

		myStatusBar = new QStatusBar;

		vl->addWidget( menuBar );
		QLabel * label1 = new QLabel( "Hello World" );
		label1->setToolTip( "Label 1" );
		QLabel * label2 = new QLabel( "Hello World 2" );
		label2->setToolTip( "Label 2" );
		vl->addWidget( label1 );
		vl->addWidget( label2 );		
		vl->addWidget( myStatusBar );	
	}
	
	bool event(QEvent * e)
	{
		if ( e->type() == QEvent::StatusTip )
		{

	
myStatusBar->showMessage(static_cast<QStatusTipEvent*>(e)->tip());
			return true;
		}
		return false;
	}


	QStatusBar * myStatusBar;
};



> -----Original Message-----
> From: Linos [mailto:info@xxxxxxxx]
> Sent: Monday, December 03, 2007 7:31 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: QStatusBar inside normal QDialog
> 
> hello i would like to add a status bar to a normal dialog to do any
> information relative to active widget in
> the dialog (with statusTip, i prefer this to a tooltip) but i cant
find
> how to do this in qt documentation, it
> seems the status bar it is only used in qmainwindow, how can i add a
> statusbar to a normal dialog? i have
> tried creating one and laying in the dialog but it does not display
> widgets statustip, any good idea on this?
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]