FAQ Database Discussion Community


QDialog remove title bar

c++,qt4,qdialog
The net is flooded with similar questions, but for all I have seen nothing suits to solve the problem at hand. In my QT-C++ app, I have a mainwindow form with some functions, there is a QPushButton, Pressing which a QDialog opens. Now, all functionalities in forms work fine, but...

Set Value to QComboBox from QStringList

c++,qt4,qcombobox
In my Qt C++ GUI application I have a QDialog window, there I have a few line-edits and I am setting the display texts by function call and setText(). I have stored the values in a QStringList (the QStringList I am populating via Database Query) and setting text as follows--...

Does destroy() method deallocate the memory of page?

memory,qt4,qml,blackberry-10
I am using destroy() method as follows: onPopTransitionEnded: { page.destroy(); } my question is does this destroy() method deallocates all the memmory occupied by the page and its child? Page{ content: Container{ ImageView{ //properties } } } will the destroy() method destroy every thing in content property of page? The...

Populating QTableWidget with database values

c++,qt4,qtablewidget
In my GUI application, I want to populate a QTableWidget with values from Oracle DB. I know it is simpler to do using QTableView and QSqlQueryModel. But I want to access the data later on itemwise, hence I want to use QTableWidget. I have successfully established connection to my oracle...

QPixmap load doesnt work

c++,qt4
I'm trying to put image to my form using QPixmap and QLabel. But i cant load image to QPixmap. Here is what i have: qDebug() << QFile("C:/img.png").exists(); - true qDebug() << map.load("C:/img.png"); - false I have this file but still cant load it. I use Qt 4.8 with static linking....

Acquire row data from QTableView

c++,qt4,qtableview
In my c++ gui app with qt, I have a button on my mainwindow, pressing which a dialog will open, in that dialog I have setup a QTableView which gets populated with data received from Oracle database. QSqlDatabase db = QSqlDatabase::addDatabase("QOCI"); db.setHostName("...."); db.setDatabaseName("..."); db.setUserName("..."); db.setPassword("..."); db.setPort(1521); if(db.open()) { qDebug()<<"OPEN SUCCESS";...

QVariant cast to base type

c++,qt4
I have some class like this: class QObjectDerived : public QObject { Q_OBJECT // ... }; Q_DECLARE_METATYPE(QObjectDerived*) When this class was stored to QVariant such behaviour occures QObjectDerived *object = new QObjectDerived(this); QVariant variant = QVariant::fromValue(object); qDebug() << variant; // prints QVariant(QObjectDerived*, ) qDebug() << variant.value<QObject*>(); // prints QObject(0x0) qDebug()...

Only allowing one instance of a pyqt4 application [duplicate]

python,qt,python-3.x,qt4,instance
This question already has an answer here: PyQt - how to detect and close UI if it's already running? 2 answers I have created a pyqt4 app and I want to make it so only one instance (of QApplication) is allowed to run. The program reads and writes audio...

Add a QGroupBox to a QButtonGroup

c++,qt,qt4,qgroupbox,qbuttongroup
I have a group of 3 QRadioButtons and 2 checkable QGroupBoxes that need to all be mutually exclusive. I like the convenience of adding my radio buttons to a QButtonGroup to automatically handle this, but I can't seem to figure out how to add the QGroupBox to the button group...

QFileDialog to open multiple files

python,qt4,qfiledialog
I am trying to show a dialog box to open multiple files but seems like it is not working: def loadFiles(self) filter = "TXT (*.txt);;PDF (*.pdf)" file_name = QtGui.QFileDialog() file_name.setFileMode(QFileDialog.ExistingFiles) names = file_name.getOpenFileNameAndFilter(self, "Open files", "C\\Desktop", filter) print names I thought that the key word was QFileDialog.ExistingFiles. What am I...

PyQt4: Non-ASCII character detected in trUtf8 string

python-2.7,utf-8,qt4,pyqt4
I'm trying to figure out how to feed the PyQt tr() or trUtf8() functions UTF-8 text. Here are examples strings: self.tr('λληνικά') self.tr(u'εληνικά') self.tr('ελνικά'.encode('utf-8')) self.tr(u'ελληικά'.encode('utf-8')) self.trUtf8('λληνικ') self.trUtf8(u'εληνιά') self.trUtf8('ελνι'.encode('utf-8')) self.trUtf8(u'ελλκά'.encode('utf-8')) The ones with self.tr display as gibberish in Qt Linguist. The ones with self.trUtf8 display fine, but they trigger a warning when...

QtDesigner for Raspberry Pi

qt4,raspberry-pi,qt-creator,qt-designer
I am building a UI with QT Designer. I need this UI to run on a Raspberry Pi. What do I need to do to make the UI for the Pi? Does it have to be written in a specific language like python or can I just write it in...

Copying values to and from QStringList to QString Array[]

c++,qt4,qstring
In my C++ GUI program, I am storing a sequence of text ( e.g. option1,option2,option3,option4,option5,option6) in the QString Array[6]. Now, I want to pass this values (i.e. all 6 of them through various functions / signals / slots) as and when required and operate on them individually. But since QString...

libvlc is unable to stop streaming & causes crash in Qt Application

visual-studio-2010,qt4,libvlc
I am creating a streaming application in QT using libvlc, which will play the RTSP streaming coming from any source. I have created it and it is working fine for me except that whenever i want to close it my application crashes. My code is as below. ThreadVlc.h <pre> #ifndef...

QDbusReply doesn't work calling a DBus function which returns a aa{sv} with Qt4?

qt4,qdbus
I have a dbus interface which works in d-feet as expected but when I want to call it from within my QT4 Application the list has zero size :( I guess, aa{sv} can be used from Qt4 via QVariantList, right? QDBusReply< QVariantList > reply = dbusinterface.call("getUsers"); QVariantList value = reply.value();...

Check, if a PDF-Reader is instaled - QDesktopServices::openUrl()

c++,qt,qt4
i want to check, if a pdf-reader is installed. The idea was to use QDesktopServices::openUrl("path/test.pdf") and if its return "false" i know that no pdf-reader is installed. The problem is, that if a pdf-reader is installed, it opens the pdf. Can I "disable" that? /edit: My solution: QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.pdf\\OpenWithProgids", QSettings::NativeFormat);...

QScintilla Font Combo Box Confliction

qt,qt4,qt5,qt5.4,qscintilla
I am using QScintilla in a Qt program of mine. I have a lexer set, so to change the font I have to change the font of the lexer. I have a font combo box so when I change the font it should change the font of the lexer. However,...

Optimization of code / implementing “for” loop instead of long “if - else if - else”

c++,for-loop,qt4
To say in brief about my QT GUI C++ program, I have 4 labels, label1, label2, label3, label4 and a spinBox, comboBox and pushButton. The functional (user operation logic) example, if spinBox value = 1, on pushButton click, current comboBox index (text) = my_stringarray[0] if spinBox value = 2, on...

Syntax highlighting not working from QMainWindow

qt,pyqt,qt4
I'm trying to implement syntax highlighting using PyQt4. The examples I've tried work fine, but as soon as I work it into an application the highlighting stops working. I've created a minimal example to recreate the issue below. I've removed all the regex except for the comment one: lines starting...

Qt Serializion custom class

c++,qt,qt4
what is wrong in my code !!!! i got the following error message: unresolved external symbol. any suggestions .. and what is the proper whay to inhert from QObject whit out getting you trying to access private member . namespace BioQt { class Location : public QObject { Q_OBJECT public:...

How do you use unicode in Qt? [duplicate]

c++,qt,unicode,encoding,qt4
This question already has an answer here: Retrieve Unicode code points > U+FFFF from QChar 2 answers I would like to use the magnifying glass (U+1F50E) Unicode symbol in a QLineEdit field. I figured out how to use 16-bit unicode symbols using QChar however I have no idea how...

Passing QString variables between QDialog forms

c++,qt4,qstring,qdialog
The problem I have encountered is a bit trickier and not similar to other problems / solutions over the net. To provide a brief idea of my application, the work-flow is shown below; I have done till fetching the data in Dialog2 and saved the data in QString variables. And...

PySide Qt tr() does not translate, context wrong?

python,qt4,translation,pyside
I want to use a QTranslator to be able to use English text labels and still have the software showing German labels. Unfortunately my app does not translate. Loading the .qm file returns True, so it is loaded correctly. The context generated by pyside-lupdate for the class is MainWindow. view...

default is not working on my switch (c++)

c++,qt4
My problem it's very simple to explain, but I have no idea to solve it. In my switch statement in the code that you can see below, the default case does not work, but if I remove the last return ""; works fine. Like something so simple can lead a...

PyQT4: Adding combobox in Qtableview

combobox,pyqt,qt4,tableview
I am new to PyQT. I am interested to add a combobox to the each row of tableView. Is it possible in PyQT 4? I know, it is possible in QT5, but not sure about PyQT. Thank you in advance for help....

QML visible property in Grid delete Item

qt,qt4,qml
I'm trying to create a QML keyboard with the following code on Qt4.8. Item { id: keyboard property string keys: "azertyuiopqsdfghjklmwxcvbn****^<" Rectangle { height: parent.height width: parent.width Grid { id: keyboardGrid rows: 4 columns: 10 spacing: 1 Repeater { model: keys.length KeyboardButton { visible: { (keys.charAt(index) == "*") ? false...

Add multiple QFrames into a single QFrame at runtime while using MSVC

visual-studio-2010,qt4
I am creating a main window having a number of frames as child frames on it. I want to add these frames at runtime and i am using the following code. in NFrame.h In NFrame.h QList<QFrame *> nFrame; and initialize them in NFrame.cpp as In Nframe.cpp for(int i=1;i<=n;i++) { nFrame[i]...

How can I enforce a 50/50 layout of two QGraphicsViews side-by-side?

c++,qt,qt4
I'm trying to lay out two QGraphicsView widgets side by side with a grid layout in Qt Designer like so, but the view unexpectedly resizes on scale and translate calls: I'm not sure what my options are for enforcing a 50/50 split. In Qt Designer, the most relevant setting on...

qInstallMsgHandler error while registering log function in Qt

qt,qt4
I am designing Qt log window, So I am using qInstallMsgHandler() function to log all the debug, critical & warning messages on to QTableWidget (in below code I have not implemented yet). I did as below int main(int argc, char *argv[]) { qInstallMsgHandler(MainWindow::logMessage); //qInstallMsgHandler(&MainWindow::logMessage); //I tried this also QApplication a(argc,...

evaluateJavaScript used for an entire file

c++,qt,qt4
I need an editor of mine to evaluate the JS code in whatever JS file I have open. However, it never does. Although the app output says QIODevice::read: device not open Here's my code (mFilename is the variable that holds the open file's filename) QFile sFile(mFilename); QTextStream in(&sFile); text =...

PyQt: translate module strings at runtime

qt4,pyqt4,translation
Strings in a QObjects translated at runtime. AFAIU, if the translator is changed, all strings are refreshed. However, strings declared at module level or even static class attributes, are translated at import time. I can see 3 ways of allowing module strings to be translated, none of which seems totally...

Making a QLabel invisible/visible after unchecking/checking QCheckBox

c++,qt,qt4,qcheckbox
I will start by describing my C++ GUI app. I have a home screen (mainwindow) which has a number of labels(kpi's) that show various data. And there is a settings button in the home screen, pressing which a settings dialog (consettingsdialog) opens which has various parameter settings for the mainwindow...

Qt App is able to access database in development machine but not on target machine

windows,qt,sqlite,qt4
I have this app that uses sqlite database. Login to the app is done by accessing the credentials in a table in the database. I am able to login on the development machine but on the target machine, i am not able to login. I built the program in release...

QT: timer is not working in changeEvent but it works in timerEvent

c++,qt,timer,qt4
I have this function is part of qtdlg.cpp. Here is the constructor for this class: qtdlg::qtdlg() { timer1.start(100, this); // 100 msec updating } void qtdlg::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui.retranslateUi(this); break; case QEvent::Timer: { // do some stuff // it never comes here! } break;...

QPushButton dimensions change when Stylesheet is apllied

qt,qt4,stylesheet,qss,qpushbutton
When I apply a style sheet on QPushButton its dimensions change. This is my style sheet declaration. QPushButton { background-color: rgb(175, 187, 199); color: black; border-width: 1px; border-top: 1px solid white; border-left: 1px solid white; border-right: 1px solid grey; border-bottom: 1px solid grey; border-style: solid; border-radius: 5; padding: 3px; padding-left:...