qt4

How to translate language in Qt on the fly

最后都变了- 提交于 2019-12-18 05:11:12
问题 I am using Translator and linguist to translate language in my application in Qt symbain, But I want to do this on the fly (on run time), I have tried the solution given by the developer network but it is not working for me #include "languagetranslator.h" #include "constants.h" #include <QSettings> #include <HelperClasses/Strings.h> #include <QTranslator> #include <AppStatus/appstatus.h> #include <QApplication> QTranslator* LanguageTranslator::current = 0; LanguageTranslator:

Setting background image for QPushButton

£可爱£侵袭症+ 提交于 2019-12-18 05:02:16
问题 I am struggling to set an background image for an QPushButton. No Success till now. Following is my code. appsWidget::appsWidget(QWidget *parent) :QWidget(parent) { QPushButton *button1 = new QPushButton("SETTINGS",this); QPushButton *button2 = new QPushButton("TEST",this); QPushButton *button3 = new QPushButton("IE",this); button1->setStyleSheet("background-image:url(config.png)"); -> No success qDebug("appWidget initialized."); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget

Setting background image for QPushButton

99封情书 提交于 2019-12-18 05:01:05
问题 I am struggling to set an background image for an QPushButton. No Success till now. Following is my code. appsWidget::appsWidget(QWidget *parent) :QWidget(parent) { QPushButton *button1 = new QPushButton("SETTINGS",this); QPushButton *button2 = new QPushButton("TEST",this); QPushButton *button3 = new QPushButton("IE",this); button1->setStyleSheet("background-image:url(config.png)"); -> No success qDebug("appWidget initialized."); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget

How to set QTextDocument margins and other properties (setHTML, print to pdf)?

我与影子孤独终老i 提交于 2019-12-18 04:18:15
问题 I have the following certificate class for producing pdf document out of some images and data. After setting image sources, I call generate() function and get test.pdf output file. The document is created based on QTextDocument class using setHtml(html) method. The problem is that I have huge white spaces around the document, while I want the title 'REPORT' with logo image to be on the very top of the page. I would also like to add lower border to the table, but as I understand it is not

A QWidget like QTextEdit that wraps its height automatically to its contents?

独自空忆成欢 提交于 2019-12-18 04:16:41
问题 I am creating a form with some QTextEdit widgets. The default height of the QTextEdit exceeds a single line of text and as the contents' height exceeds the QTextEdit's height, it creates a scroll-bar to scroll the content. I would like to override this behaviour to create a QTextEdit that would rather wrap its height to its contents. This means that the default height would be one line and that on wrapping or entering a new line, the QTextEdit would increase its height automatically. Whenever

Run Linux commands from Qt4

我是研究僧i 提交于 2019-12-18 04:09:22
问题 How can I run command-line programs under Linux from Qt4? And of course I want to obtain the output in some way I can use. I'd use it for an ls | grep , but it's good to know for any future issues. 回答1: QProcess p; p.start( /* whatever your command is, see the doc for param types */ ); p.waitForFinished(-1); QString p_stdout = p.readAllStandardOutput(); QString p_stderr = p.readAllStandardError(); 回答2: Use QProcess. 回答3: What about using popen? 来源: https://stackoverflow.com/questions/2148185

Run Linux commands from Qt4

梦想与她 提交于 2019-12-18 04:09:06
问题 How can I run command-line programs under Linux from Qt4? And of course I want to obtain the output in some way I can use. I'd use it for an ls | grep , but it's good to know for any future issues. 回答1: QProcess p; p.start( /* whatever your command is, see the doc for param types */ ); p.waitForFinished(-1); QString p_stdout = p.readAllStandardOutput(); QString p_stderr = p.readAllStandardError(); 回答2: Use QProcess. 回答3: What about using popen? 来源: https://stackoverflow.com/questions/2148185

switch/case statement in C++ with a QString type

半腔热情 提交于 2019-12-18 03:49:34
问题 I want to use switch-case in my program but the compiler gives me this error: switch expression of type 'QString' is illegal How can I use the switch statement with a QString ? My code is as follows: bool isStopWord( QString word ) { bool flag = false ; switch( word ) { case "the": flag = true ; break ; case "at" : flag = true ; break ; case "in" : flag = true ; break ; case "your": flag = true ; break ; case "near": flag = true ; break ; case "all": flag = true ; break ; case "this": flag =

qt5.1.1 mysql ubuntu QMYSQL driver not loaded

[亡魂溺海] 提交于 2019-12-18 03:43:27
问题 I'm trying to access mysql using Qt5.1.1 but i am getting the error the error below. I also searched a lot on google but unable to fix it.Please suggest me a solution so that i am able to resolve this error. error: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QSqlError(-1, “ driver not loaded”, “ driver not loaded”) code: #include <QCoreApplication> #include <QDebug> #include <QDir> #include <QtSql> #include <QSqlDriver> #include

Set color to a QTableView row

我只是一个虾纸丫 提交于 2019-12-18 03:37:08
问题 void MyWindow::initializeModelBySQL(QSqlQueryModel *model,QTableView *table,QString sql){ model = new QSqlQueryModel(this); model->setQuery(sql); } With this method i can set a QSQlQueryModels to my QTableviews. But How i can set color to a row based on a cell value? 回答1: The view draws the background based on the Qt::BackgroundRole role of the cell which is the QBrush value returned by QAbstractItemModel::data(index, role) for that role. You can subclass the QSqlQueryModel to redefine data()