Category Archives: Qt

create a custom dialog box with multi line input in qt

//create a custom dialog box with multi line input void MainWindow::createMultilineInput() { //class variable dlgMultiLine = new QDialog(this);   //local variable QGridLayout *gridLayout = new QGridLayout(dlgMultiLine);   //class variable txtMultiline = new QPlainTextEdit();   txtMultiline->setObjectName(QString::fromUtf8("txtMultiline")); gridLayout->addWidget(txtMultiline, 0, 0, 1, 1); … Continue reading

Posted in Qt, Qt-Tips Tagged , ,

show data in external window with custom widget in qt

Sometime you need to show data in external window with custom widget(s). This little code will help you. function showCustomWidget() {   QDialog *dlgMultiLine = new QDialog(); QGridLayout *gridLayout = new QGridLayout(dlgMultiLine); QPlainTextEdit *txtMultiline = new QPlainTextEdit();   txtMultiline->setPlainText(this->toPlainText());   … Continue reading

Posted in Qt, Qt-Tips Tagged , , ,

getting all files from subdirectories recursively with c using qt framework/

// Display a dialog to the user to choose his music directory QString directory_path = QFileDialog::getExistingDirectory(this, tr("Select your music directory"), QDir::currentPath());   // Then create an instance of our QDirIterator, which takes as parameters // the directory, a QDir filter … Continue reading

Posted in Qt, Qt-Tips

Create single instance application in Qt 4 : Qt Tip #1

Many times we want only single instance of application. How can we achieve this. I’m going to show a simple way to achieve this. We need a Utility that is freely provided by Qt guys . Click here to know … Continue reading

Posted in Featured, Qt, Qt-Tips Tagged , , ,

Simulate a Key event press/release in QT 4

QApplication::sendEvent(this, new QKeyEvent (QEvent::KeyPress, Qt::Key_Dead_Diaeresis, Qt::NoModifier, QString("ยจ")));   //Another way I guess easy to understand :) //Although both are same QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_Escape, Qt::NoModifier); QApplication::sendEvent(this, &keyEvent);

Posted in Featured, Qt Tagged , , , ,

Qt Code Example: New File | Open File | Save File | Save as File | File Print | Print Preview | File Print Preview | Print Preview

These are few code snippet taken from Qt examples. I’m making easier to look for particular functions. That’s it . New File Open File Save File Save as File File Print Print Preview File Print Preview Print Preview Save as … Continue reading

Posted in Featured, Qt Tagged , , , , , ,

Qt Code Example: MessageBox

  QMessageBox::about(this, tr("About Syntax Highlighter"), tr("<p>The <b>Syntax Highlighter</b> example shows how " \ "to perform simple syntax highlighting by subclassing " \ "the QSyntaxHighlighter class and describing " \ "highlighting rules using regular expressions.</p>"));

Posted in Featured, Qt Tagged ,

Qt Code Example : Open File

void MainWindow::openFile(const QString &path) { QString fileName = path;   if (fileName.isNull()) fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", "C++ Files (*.cpp *.h)");   if (!fileName.isEmpty()) { QFile file(fileName); if (file.open(QFile::ReadOnly | QFile::Text)) editor->setPlainText(file.readAll());   } }

Posted in Featured, Qt Tagged