Exemplo n.º 1
18
void NewAccount::addAccountDescription ()
  {
    // Function for adding or editing an account description.
    QDialog *description = new QDialog ( this, "description", TRUE );
    description->setCaption ( "Notes" );
    QMultiLineEdit *enter = new QMultiLineEdit ( description );
    enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
    enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
    enter->setWordWrap ( QMultiLineEdit::WidgetWidth );
    if ( accountdescription != "(NULL)" )
      enter->setText ( accountdescription );
    if ( description->exec () == QDialog::Accepted )
      accountdescription = enter->text ();
  }
Exemplo n.º 2
0
void classISQL::SaveSQL()
{
    QMultiLineEdit  *txt;
    QString         qsFileName;

    if ( pTabBar->currentTab() == 0 )
    {
        txt = txtSQL;
        qsFileName = qsSQLFileName;
    }
    else
    {
        txt = txtResults;
        qsFileName = qsResultsFileName;
    }

    if ( qsFileName == "" )
    {
        SaveAsSQL();
        return;
    }

    // TRY TO SAVE THE FILE
    QFile hFile( qsFileName );

    if ( !hFile.open( IO_WriteOnly ) )
        return;

    hFile.writeBlock( txt->text(), txt->text().length() );
    hFile.close();

}
Exemplo n.º 3
0
void classISQL::SaveAsSQL()
{
    QMultiLineEdit  *txt;
    QString         qsFileName;

    if ( pTabBar->currentTab() == 0 )
    {
        txt = txtSQL;
        qsFileName = qsSQLFileName;
    }
    else
    {
        txt = txtResults;
        qsFileName = qsResultsFileName;
    }

    // LET USER PICK A FILE
    QString qsFile = QFileDialog::getSaveFileName( qsFileName );
    if ( qsFile.isNull() )
        return;

    // TRY TO SAVE THE FILE
    QFile hFile( qsFile );

    if ( !hFile.open( IO_WriteOnly ) )
        return;

    hFile.writeBlock( txt->text(), txt->text().length() );
    hFile.close();

    if ( pTabBar->currentTab() == 0 )
    {
        qsSQLFileName = qsFile;
    }
    else
    {
        qsResultsFileName = qsFile;
    }

}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
  QApplication app(argc, argv);

  QWidget *messageWindow = new QWidget();
  app.setMainWidget(messageWindow);
  messageWindow->setFixedSize(220, 150);

  QMultiLineEdit *messages = new QMultiLineEdit(messageWindow);
  messages->setGeometry(10, 10, 200, 100);
  QPushButton *clear = new QPushButton("Clear", messageWindow);
  clear->setGeometry(10, 120, 95, 20);
  QPushButton *hide = new QPushButton("Hide", messageWindow);
  hide->setGeometry(115, 120, 95, 20);

  messageWindow->setCaption("einfacher Dialog");
  messages->setReadOnly(true);
  messages->append("Initialisierung abgeschlossen\n");

  messageWindow->show();

  return app.exec();
}
Exemplo n.º 5
0
void classISQL::OpenSQL()
{
    QMultiLineEdit *txt;

    if ( pTabBar->currentTab() == 0 )
    {
        pSliderRecentSQL->setValue( pSliderRecentSQL->maxValue() );
        txt = txtSQL;
    }
    else
        txt = txtResults;

    // LET USER PICK A FILE
    QString qsFile = QFileDialog::getOpenFileName();
    if ( qsFile.isNull() )
        return;

    // TRY TO LOAD THE FILE
    QFile hFile( qsFile );

    if ( !hFile.open( IO_ReadOnly ) )
        return;

    txt->setAutoUpdate( FALSE );
    txt->clear();

    QTextStream t( &hFile );
    while ( !t.eof() )
    {
        QString s = t.readLine();
        txt->append( s );
    }
    hFile.close();

    txt->setAutoUpdate( TRUE );
    txt->repaint();

    if ( pTabBar->currentTab() == 0 )
        qsSQLFileName = qsFile;
    else
        qsResultsFileName = qsFile;

    setTextType( 0 );
}
Exemplo n.º 6
0
    void resizeEvent(QResizeEvent*)
    {
	mle->resize(width(),height());
    }
Exemplo n.º 7
0
    EncapsulatedQtWidget(Widget parent) :
	QXtWidget("editor", parent, TRUE)
    {
	mle = new QMultiLineEdit(this);
	mle->setText(QTEDMSG);
    }
Exemplo n.º 8
0
ExampleWidget::ExampleWidget( QWidget *parent, const char *name )
    : QWidget( parent, name )
{
    // Make the top-level layout; a vertical box to contain all widgets
    // and sub-layouts.
    QBoxLayout *topLayout = new QVBoxLayout( this, 5 );

    // Create a menubar...
    QMenuBar *menubar = new QMenuBar( this );
    menubar->setSeparator( QMenuBar::InWindowsStyle );
    QPopupMenu* popup;
    popup = new QPopupMenu( this );
    popup->insertItem( "&Quit", qApp, SLOT(quit()) );
    menubar->insertItem( "&File", popup );

    // ...and tell the layout about it.
    topLayout->setMenuBar( menubar );

    // Make an hbox that will hold a row of buttons.
    QBoxLayout *buttons = new QHBoxLayout( topLayout );
    int i;
    for ( i = 1; i <= 4; i++ ) {
	QPushButton* but = new QPushButton( this );
	QString s;
	s.sprintf( "Button %d", i );
	but->setText( s );

	// Set horizontal stretch factor to 10 to let the buttons
	// stretch horizontally. The buttons will not stretch
	// vertically, since bigWidget below will take up vertical
	// stretch.
	buttons->addWidget( but, 10 );
	// (Actually, the result would have been the same with a
	// stretch factor of 0; if no items in a layout have non-zero
	// stretch, the space is divided equally between members.)
    }

    // Make another hbox that will hold a left-justified row of buttons.
    QBoxLayout *buttons2 = new QHBoxLayout( topLayout );

    QPushButton* but = new QPushButton( "Button five", this );
    buttons2->addWidget( but );

    but = new QPushButton( "Button 6", this );
    buttons2->addWidget( but );

    // Fill up the rest of the hbox with stretchable space, so that
    // the buttons get their minimum width and are pushed to the left.
    buttons2->addStretch( 10 );

    // Make  a big widget that will grab all space in the middle.
    QMultiLineEdit *bigWidget = new QMultiLineEdit( this );
    bigWidget->setText( "This widget will get all the remaining space" );
    bigWidget->setFrameStyle( QFrame::Panel | QFrame::Plain );

    // Set vertical stretch factor to 10 to let the bigWidget stretch
    // vertically. It will stretch horizontally because there are no
    // widgets beside it to take up horizontal stretch.
    //    topLayout->addWidget( bigWidget, 10 );
    topLayout->addWidget( bigWidget ); 

    // Make a grid that will hold a vertical table of QLabel/QLineEdit
    // pairs next to a large QMultiLineEdit.

    // Don't use hard-coded row/column numbers in QGridLayout, you'll
    // regret it when you have to change the layout.
    const int numRows = 3;
    const int labelCol = 0;
    const int linedCol = 1;
    const int multiCol = 2;

    // Let the grid-layout have a spacing of 10 pixels between
    // widgets, overriding the default from topLayout.
    QGridLayout *grid = new QGridLayout( topLayout, 0, 0, 10 );
    int row;

    for ( row = 0; row < numRows; row++ ) {
	QLineEdit *ed = new QLineEdit( this );
	// The line edit goes in the second column
	grid->addWidget( ed, row, linedCol );	

	// Make a label that is a buddy of the line edit
	QString s;
	s.sprintf( "Line &%d", row+1 );
	QLabel *label = new QLabel( ed, s, this );
	// The label goes in the first column.
	grid->addWidget( label, row, labelCol );
    }

    // The multiline edit will cover the entire vertical range of the
    // grid (rows 0 to numRows) and stay in column 2.

    QMultiLineEdit *med = new QMultiLineEdit( this );
    grid->addMultiCellWidget( med, 0, -1, multiCol, multiCol );

    // The labels will take the space they need. Let the remaining
    // horizontal space be shared so that the multiline edit gets
    // twice as much as the line edit.
    grid->setColStretch( linedCol, 10 );
    grid->setColStretch( multiCol, 20 );

    // Add a widget at the bottom.
    QLabel* sb = new QLabel( this );
    sb->setText( "Let's pretend this is a status bar" );
    sb->setFrameStyle( QFrame::Panel | QFrame::Sunken );
    // This widget will use all horizontal space, and have a fixed height.

    // we should have made a subclass and implemented sizePolicy there...
    sb->setFixedHeight( sb->sizeHint().height() );

    sb->setAlignment( AlignVCenter | AlignLeft );
    topLayout->addWidget( sb );

    topLayout->activate();
}
Exemplo n.º 9
0
ToolbarDemo::ToolbarDemo()
    : QMainWindow(0, "Toolbar Demo")
{

	//主窗口本身是一个高级容器

	//建立动作
	QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
		*fileSaveAsAction, *filePrintAction, *fileCloseAction,
		*fileQuitAction;
	fileNewAction = new QAction( "New", tr("新建(&N)"), 
		CTRL+Key_N, this, "new" );
	connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
	fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), 
		tr("打开(&O)"), CTRL+Key_O, this, "open" );
	connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
	QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
		QPixmap( fileopen ) );
	fileOpenAction->setWhatsThis( tr(fileOpenText) );

	fileSaveAction = new QAction( "Save File", QPixmap( filesave ), 
		tr("保存(&S)"), CTRL+Key_S, this, "save" );
	connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
	fileSaveAction->setWhatsThis( tr(fileSaveText) );

	fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 
		0,  this, "save as" );
	connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
	fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
	filePrintAction = new QAction( "Print File", QPixmap( fileprint ), 
		tr("打印(&P)"), CTRL+Key_P, this, "print" );
	connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
	filePrintAction->setWhatsThis( tr(filePrintText) );

	fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, 
		this, "close" );
	connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );

	fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, 
		this, "quit" );
	connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));


	//建立按钮条
	QToolBar* fileTools = new QToolBar( this, "file operations" );
	fileTools->setLabel( "File Operations" );
	fileOpenAction->addTo( fileTools );
	fileSaveAction->addTo( fileTools );
	filePrintAction->addTo( fileTools );
	(void)QWhatsThis::whatsThisButton( fileTools );


	//建立文件菜单
	QPopupMenu * file = new QPopupMenu( this );
	menuBar()->insertItem( tr("文件(&F)"), file );
	fileNewAction->addTo( file );
	fileOpenAction->addTo( file );
	fileSaveAction->addTo( file );
	fileSaveAsAction->addTo( file );
	file->insertSeparator();
	filePrintAction->addTo( file );
	file->insertSeparator();
	fileCloseAction->addTo( file );
	fileQuitAction->addTo( file );

	//建立帮助菜单
	QPopupMenu * help = new QPopupMenu( this );
	menuBar()->insertSeparator();
	menuBar()->insertItem( tr("帮助(&H)"), help );
	help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
	help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
	help->insertSeparator();
	help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);


	QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
	e->setFocus();
	setCentralWidget( e );
	statusBar()->message( tr("准备就绪"), 2000 );
	resize( 400, 400 );

}
Exemplo n.º 10
0
ThemeDemo::ThemeDemo()
    : QMainWindow(0, "Toolbar Demo")
{

	appFont = QApplication::font();

	//建立动作
	QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
		*fileSaveAsAction, *filePrintAction, *fileCloseAction,
		*fileQuitAction;
	fileNewAction = new QAction( "New", tr("新建(&N)"), 
		CTRL+Key_N, this, "new" );
	connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
	fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), 
		tr("打开(&O)"), CTRL+Key_O, this, "open" );
	connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
	QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
		QPixmap( fileopen ) );
	fileOpenAction->setWhatsThis( tr(fileOpenText) );

	fileSaveAction = new QAction( "Save File", QPixmap( filesave ), 
		tr("保存(&S)"), CTRL+Key_S, this, "save" );
	connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
	fileSaveAction->setWhatsThis( tr(fileSaveText) );

	fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 
		0,  this, "save as" );
	connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
	fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
	filePrintAction = new QAction( "Print File", QPixmap( fileprint ), 
		tr("打印(&P)"), CTRL+Key_P, this, "print" );
	connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
	filePrintAction->setWhatsThis( tr(filePrintText) );

	fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, 
		this, "close" );
	connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );

	fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, 
		this, "quit" );
	connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));


	//建立按钮条
	QToolBar* fileTools = new QToolBar( this, "file operations" );
	fileTools->setLabel( "File Operations" );
	fileOpenAction->addTo( fileTools );
	fileSaveAction->addTo( fileTools );
	filePrintAction->addTo( fileTools );
	(void)QWhatsThis::whatsThisButton( fileTools );


	//建立文件菜单
	QPopupMenu * file = new QPopupMenu( this );
	menuBar()->insertItem( tr("文件(&F)"), file );
	fileNewAction->addTo( file );
	fileOpenAction->addTo( file );
	fileSaveAction->addTo( file );
	fileSaveAsAction->addTo( file );
	file->insertSeparator();
	filePrintAction->addTo( file );
	file->insertSeparator();
	fileCloseAction->addTo( file );
	fileQuitAction->addTo( file );

	//建立Style菜单
	QPopupMenu *style = new QPopupMenu( this );
	style->setCheckable( TRUE );
	menuBar()->insertItem( tr("风格(&S)") , style );
	sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) );
	sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) );
	sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) );
	sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) );
	sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) );
	sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) );
	sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) );

	//建立帮助菜单
	QPopupMenu * help = new QPopupMenu( this );
	menuBar()->insertSeparator();
	menuBar()->insertItem( tr("帮助(&H)"), help );
	help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
	help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
	help->insertSeparator();
	help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);


	QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
	e->setFocus();
	setCentralWidget( e );
	statusBar()->message( tr("准备就绪"), 2000 );
	resize( 400, 400 );

}
Exemplo n.º 11
0
QString JabberSearch::condition(bool &bXSearch)
{
    bXSearch = m_bXData;
    QString res;
    if (m_bXData)
        res += "x:data";

    QObjectList *l = queryList("QLineEdit");
    QObjectListIt it( *l );
    QObject *obj;
    while ((obj = it.current()) != 0 ){
        QLineEdit *edit = static_cast<QLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ";";
            res += edit->name();
            res += "=";
            res += quoteChars(edit->text(), ";");
        }
        ++it;
    }
    delete l;

    l = queryList("QComboBox");
    QObjectListIt it1( *l );
    while ((obj = it1.current()) != 0 ){
        CComboBox *box = static_cast<CComboBox*>(obj);
        if (box->currentText().isEmpty()){
            ++it1;
            continue;
        }
        if (!res.isEmpty())
            res += ";";
        res += box->name();
        res += "=";
        res += quoteChars(box->value(), ";");
        ++it1;
    }
    delete l;

    l = queryList("QCheckBox");
    QObjectListIt it2( *l );
    while ((obj = it2.current()) != 0 ){
        QCheckBox *box = static_cast<QCheckBox*>(obj);
        if (!box->isChecked()){
            ++it2;
            continue;
        }
        if (!res.isEmpty())
            res += ";";
        res += box->name();
        res += "=1";
        ++it2;
    }
    delete l;

    l = queryList("QMultiLineEdit");
    QObjectListIt it3( *l );
    while ((obj = it3.current()) != 0 ){
        QMultiLineEdit *edit = static_cast<QMultiLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ";";
            res += edit->name();
            res += "=";
            res += quoteChars(edit->text(), ";");
        }
        ++it3;
    }
    delete l;

    if (!m_key.empty()){
        if (!res.isEmpty())
            res += ";";
        res += "key=";
        res += quoteChars(QString::fromUtf8(m_key.c_str()), ";");
    }

    return res;
}
Exemplo n.º 12
0
QString JabberSearch::condition(QWidget *w)
{
    QString res;
    if (m_bXData && (w == NULL))
        res += "x:data";

    if (w == NULL)
        w = this;

    QObjectList *l = w->queryList("QLineEdit");
    QObjectListIt it( *l );
    QObject *obj;
    while ((obj = it.current()) != 0 ){
        QLineEdit *edit = static_cast<QLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ';';
            res += edit->name();
            res += '=';
            res += quoteChars(edit->text(), ";");
        }
        ++it;
    }
    delete l;

    l = w->queryList("QComboBox");
    QObjectListIt it1( *l );
    while ((obj = it1.current()) != 0 ){
        CComboBox *box = static_cast<CComboBox*>(obj);
        if (box->currentText().isEmpty()){
            ++it1;
            continue;
        }
        if (!res.isEmpty())
            res += ';';
        res += box->name();
        res += '=';
        res += quoteChars(box->value(), ";");
        ++it1;
    }
    delete l;

    l = w->queryList("QCheckBox");
    QObjectListIt it2( *l );
    while ((obj = it2.current()) != 0 ){
        QCheckBox *box = static_cast<QCheckBox*>(obj);
        if (!res.isEmpty())
            res += ';';
        res += box->name();
        res += box->isChecked() ? "=1" : "=0";
        ++it2;
    }
    delete l;

    l = w->queryList("QMultiLineEdit");
    QObjectListIt it3( *l );
    while ((obj = it3.current()) != 0 ){
        QMultiLineEdit *edit = static_cast<QMultiLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ';';
            res += edit->name();
            res += '=';
            res += quoteChars(edit->text(), ";");
        }
        ++it3;
    }
    delete l;

    if (!m_key.isEmpty() && (w == NULL)){
        if (!res.isEmpty())
            res += ';';
        res += "key=";
        res += quoteChars(m_key, ";");
    }
    return res;
}