Re: [Interest] json file handling
On 15-4-2015 17:25, Thiago Macieira wrote: On Wednesday 15 April 2015 16:36:15 André Somers wrote: The dilemma I'm in is, how can I tell the json writer to append to a current json file without loading the whole file back in memory (eg read json from file-edit in Qt-write back to file). Because, after a while, I suppose the file will get quite large. I don't think JSON is particulary suitable for this kind of application (and neither is XML). CBOR might be, since it does support undefined length maps and arrays. I'm not familiar with that format, but I'll look it up. I guess the choice for JSON or XML is made due to convenience though, as classes to read and write these are readily available. I doubt the same can be said of CBOR. As for XML, the format may not be suitable but QXmlStreamWriter is since it keeps the state of which tags it needs to close and allows you to simply stream data into it. On the receiver side, QXmlStreamReader is capable of receiving incomplete data and making the best it can with what has been completed. I'd expect a log-file like output to be well defined at any moment in time, or as close as possible to that. So, while QXmlStreamWriter is suitable, it does not produce a valid XML file until you finalize the write. That may not be what you want (even though QXmlStreamReader could be used to parse the incomplete file*). I think a simpler aproach may be a better one in such cases: simply add new values to the end of a file when the become available. No fancy markup languages to wrap them. That will result in a smaller file (especially compared to XML), faster writing and no problems reading the data back in. Simple CSV will do if you want a text-based file, but a binary file could also function really well if that is not needed. Just append to the file when you have new data available. Such approaches have worked with log files for decades :-) André *) Though I seem to remember there are actually some problems with that in reality. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] a few questions about QML Components
Nurmi J-P schreef op 19-5-2014 14:29: On 19 May 2014, at 12:51, Alexander Ivash elder...@gmail.com wrote: I was trying to use QML components in simple android application but confronted several issues: 1. I couldn't find any API allowing to adjust widths of columns in TableView based on the content. Do I understand right that the only way to achieve this is to go through all the entries in model manually and calculate maximum width using 'paintedWidth' of Text element? Does the better way exist? For future would be really nice to have some property like 'autoAdjustColumns’. QtQuick.Controls 1.2 (Qt 5.3) introduces TableView::resizeColumnsToContens() and TableViewColumn::resizeToContents(). Stupid question probably, but why arn't these written in a declarative way? André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Can a view somehow notify a model of which rows it is going to show on screen?
Mark Gaiser schreef op 20-4-2014 4:04: Hi, the title says it all... I can't find any signals that expose this information in the model. I would like to know this from the QML ListView component. What i can do is tell the model where the current y position is in the models content and the height of each row. That gives me enough information to calculate which rows are visible, but i'm hoping there is some way out there that i just haven't discovered yet. I'm asking because i have a big dataset and only want to sort the data that is visible for the user (partial_sort along with nth_element will do that). AFAIK, there are no facilities for that. The way to know what data is needed, is simply to respond to the data() calls in QAbstractItemModel. Only rows that are needed are (should be) fetched. But that information is not shared in advance. Are you sure that this is your performance bottleneck though? To me, it sounds like premature optimization to worry about this and to try to optimize this. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] aboutQt (Qt 4.8) dialog lacks vital information - people relying on it violate license terms(?)
Thiago Macieira schreef op 6-4-2014 4:00: What's more, there are a few requirements that cannot be met by a dialog. For example, everyone needs to distribute Qt themselves, on a server they own or are responsible for, not rely Qt Project or Digia to have the sources. Nonsense. You don't need to have to run a server serving Qt. Where does it say that in the license? You have to provide the sources on request, and one way to fulfill that obligation is to run a server. Another is to simply handle the request if and when they arrive, and supply the sources on another medium. We simply have the sources in store in case anyone^H^H^H any customer asks for them. If they want to receive Qt from us, we will comply. We never had that request though. They simply want working software so far. Note that our software also isn't available for sale online. It comes with the hardware devices they buy, though updates are provided online. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] DPI
igor.mironc...@gmail.com schreef op 23-2-2014 13:24: Hi. I want to determine how much pixels in 10 mm. I use the next calculations: staticconstqrealfingerSize=0.0393700787*10; staticconstqrealh= (qreal)QApplication::desktop()-physicalDpiY()*fingerSize; And this calculations return to me 28 that on my desktop is 5 mm only. 0.0393700787 is how much inches in millimeter... What am I doing wrong? Are you sure that the right physicalDpi is returned? That is not a value you can absolutely rely on. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QSqlQuery
Igor Mironchik schreef op 26-1-2014 16:29: Hi. I have some questions about database support in Qt 5. First of all, is it safe to transfer a QSqlQuery instance from one thread to another to process him in another thread. I.e. I want to execute SELECT query on DB thread and return a QSqlQuery from that thread to the GUI thread, where I will navigate and show users the result of the query. No, that is not safe. You can use database access from threads, but every thread needs it own QSqlDatabase instance of the database connection. The documentation states: A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported. (http://qt-project.org/doc/qt-4.8/threads-modules.html#threads-and-the-sql-module) André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTableView column format
Muhammad Bashir Al-Noimi schreef op 25-1-2014 12:13: On 01/22/2014 10:24 AM, André Somers wrote: If you want to modify it at the 'view' end, you should use a QStyledItemDelegate subclass and install that on the view, or on a specific column of the view. I did that exactly but unfortunately it didn't work :( May you please tell me what's wrong?! Your delegate is dealing with the editor, but not with the display. Try reimplementing the displayText method. Also, check if the data type you get from the database really is numerical. SQLite can be weird with data types in my experience. André I'm still get 5.25446e+06 for 5254458.963 I call the following: --- ui-tableView-setModel(_tableModel); ui-tableView-resizeColumnsToContents(); EcsLongDigitDelegate *delegate = new EcsLongDigitDelegate; ui-tableView-setItemDelegateForColumn(2, delegate); --- Database table (SQLite): --- CREATE TABLE names (id INTEGER PRIMARY KEY NOT NULL ,nam_full_name TEXT,nam_id DOUBLE DEFAULT (null) ); --- Delegate class: --- #include ecslongdigitdelegate.h EcsLongDigitDelegate::EcsLongDigitDelegate(QObject *parent) : QStyledItemDelegate(parent) { } QWidget *EcsLongDigitDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem option, const QModelIndex index) const { QDoubleSpinBox *editor = new QDoubleSpinBox(parent); editor-setFrame(false); editor-setMinimum(0); editor-setDecimals(3); editor-setMaximum(); return editor; } void EcsLongDigitDelegate::setEditorData(QWidget *editor, const QModelIndex index) const { double value = index.model()-data(index, Qt::DisplayRole).toDouble(); QDoubleSpinBox *spinBox = static_castQDoubleSpinBox*(editor); spinBox-setValue(value); } void EcsLongDigitDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex index) const { QDoubleSpinBox *spinBox = static_castQDoubleSpinBox*(editor); spinBox-interpretText(); double value = spinBox-value(); model-setData(index, value, Qt::DisplayRole); } void EcsLongDigitDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem option, const QModelIndex index) const { editor-setGeometry(option.rect); } --- ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to center the check box.
william.croc...@analog.com schreef op 29-12-2013 15:25: Gang: I have a QTableView which uses a custom model based on QAbstractItemModel. The model sets the Qt::ItemIsUserCheckable flag for one of the columns and the model data() function responds to the Qt::CheckStateRole for the same column. The result is a working check box in the corresponding column of the table view. This is all good. My problem is that the check box is presented flush left in the column and I would like it to be centered. The closest I could find was Qt::TextAlignmentRole which didn't sound right or have any affect. Any help would be appreciated. There is no easy way to make the check box appear aligned differently. The only way I know of, is to create your own delegate and do the rendering yourself (using QStyle to do the hard work, of course). André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Shift+Tab Shortcut
Op 20-9-2013 21:13, Daniel Otto Bolognani schreef: Hello list! We ported our software from QT3 Support to Pure QT4 and now we are facing some different behaviour on the shortcuts, we have managed almost all of the problems, unless the Shift+Tab shortcut that we need to intercept. When it was Qt3 Support we had this: Q3Action *q3act = new Q3Action(this); QKeySequence *ks = new QKeySequence(Qt::Key_Backtab); q3act-setAccel(*ks); connect(q3act,SIGNAL(activated()),this,SLOT(keypress())); And when pressed, the SLOT keypress was called and everything was working like it should. To port to QT4 we did this: QAction *act3 = new QAction(this); QKeySequence *ks = new QKeySequence(Qt::Key_Backtab); act3-setShortcut(*ks); addAction(act3); connect(act3,SIGNAL(triggered()),this,SLOT(keypress())); All the other shortcuts worked unless the backtab (shift+tab)! We have tried to use this on the keypress event too: void keyPressEvent( QKeyEvent * e ) { // Even if I test Qt::Key_Tab it doens't work either if ((e-modifiers()==Qt::ShiftModifier e-key() == Qt::Key_Backtab) || e-key()==Qt::Key_Backtab) { QMessageBox msgbox; msgbox.setText(backtab); msgbox.exec(); } } It hadn't worked either. The only thing that resolved this was to grab the FocusOut event and test if it was a backtab reason, but in my personal opinion it is an horrible solution! Aren't these 2 other methods supposed to work? What are we doing wrong? Thanks in advance, Daniel ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest Did you try installing an eventfilter on your QApplication object? André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QFileDialog is lovelier the second time around...
Op 14-6-2013 19:27, Constantin Makshin schreef: Try non-static QFileDialog members -- it's more likely to ignore various system [shell] extensions. And way less likely to look and feel anything close to what the user expects in a file dialog on his platform... At least, on windows, the Qt file dialog is horrible IMHO. André On Jun 14, 2013 3:11 PM, Mojmír Svoboda mojmir.svob...@warhorsestudios.cz mailto:mojmir.svob...@warhorsestudios.cz wrote: Hello again, I tried to use QFileDialog for classic file selection, but it feels very sluggish, expecially the first time. I think it's due to heavy dll dependencies that are to be loaded, in my case it makes ~85 dlls. I wonder why of course and I'd like to know whether there is some more lightweight version of open file dialogue perhaps? Many thanks, Mojmir ___ Interest mailing list Interest@qt-project.org mailto:Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Place a QWidget below a button (and follow it!)
Op 13-6-2013 19:37, william.croc...@analog.com schreef: In details, I have a widget that will display a floating window when the user clicks on a QToolButton. This floating widget must be placed below the button that summoned its soul, and if the main window moves, the floating window must be positioned in the same place. Reimplement the moveEvent of the main window (which has the tool button as a child.) In it, reevaluate the position of the child tool button (to be tracked) and move the floating window as required. Converting widget positions in and out of the global coordinate system will come in handy. While Bill is right, there is another way that allows you to do this without changing the main window for it: event filters. That will allow you to keep all the code you need for this in one place, in the widget that you want to make move. What I'd do, is give that widget a constructor argument with a pointer to the widget to follow around. Using QWidget::window, you find out what the window is the widget to be followed lives in. Install an event filter on that window-widget. If you use scrollable views somewhere, you'll need to iterate up yourself, to install the event filter for every widget in between too. In your widget-that-follows, reimplement the eventFilter(QObject*, QEvent*) method, and look for move and resize events. If you get these, you again take the geometry of the widget-to-follow, and use the mapToGlobal function of the widget-to-follow to get the global coordinates. Then, re-position your widget-that-follows to those coordinates. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Container members in abstract base class?
Op 22-5-2013 21:34, Thiago Macieira schreef: On quarta-feira, 22 de maio de 2013 16.52.29, Jonathan Greig wrote: Thank you André. The dynamic_cast worked perfectly. I'm from a C background and have been doing C-style casts for years without any major problems. Apparently this guy has also:) http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dyna mic-cast A C cast is equivalent to a chain of reinterpret_cast and const_cast. It does not do static casting or dynamic casting, which means it will not do pointer adjustments properly. So, as a rule of thumb: do not use C-style casts in C++ code and always use the least invasive C++ cast operator that you can use. And another rule of thumb: dynamic_casts are always checked[*], all the other casts are never checked. You're overlooking our very own qobject_cast. That one works on QObject derived classes without requiring the use of RTTI in the compiler, and work across library boundaries. So, if your class inherits QObject, I'd prefer qobject_cast instead. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt Sensors, can it support CPU, GPU and HDD sensors as well?
Op 14-5-2013 18:24, Mark schreef: On Tue, May 14, 2013 at 3:37 PM, Thiago Macieira thiago.macie...@intel.com wrote: On terça-feira, 14 de maio de 2013 10.54.46, Mark wrote: Can the Qt Sensor package add support for that? I think so. But how since the base class is obviously a little too focused on other types of sensors.. Or would there simply be a second base class for heat based sensors? So i guess the base would be QHeatSensor. Then for the actual sensors it would look somewhat like: QCpuSensor : public QHeatSensor QGpuSensor : public QHeatSensor ... But then you still have other sensors. Last one that comes to mind is fan speed. A CPU also has a fan speed sensor so how would that work? Another base for speed control QFanSpeed which is then also inherited by the QCpuSensor? It would look like this: QCpuSensor : public QHeatSensor, public QFanSpeed That API seems unlikely to me. It seems far more likely that we'd see a QHeatSensor and some API to first enumerate the available heat sensors, and then get them. Or, perhaps, we'd see an even more generic sensor like QSimpleScalarSensor that could contain anything from a heat, a fan speed to a voltage. You'd still need API to enumerate and get them, of course. However, I'm not working on this, so don't rely on my answer :-) André Are there any plans to implement any of this (thread subject)? ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QSqlDatabase
Op 7-5-2013 18:06, Duane schreef: I don't think this is a Qt error, nor an error in our apps as nothing has chanced in them. I'm assuming it something else affecting the server. We aren't the only application on this database. I need some way to find what is causing it. I am adding some debugging to report the database errors but the .err file from mysql shows no errors so I am not optimistic. You might want to investigate the stability of your network connection between your server and your client. André One thing that I noticed, we have multiple apps and on this installation one set of apps is running using Qt4.5.1 and another set is using 4.7.1. They both use the plugins for MySql. I'm wondering if there could be some issue with that? No, it shouldn't be. I don't think so either. I have checked a couple of other installations that don't have this problem and they are set up similarly. I notice that the others ones have a higher number of max connections so I'm looking at that. I've increased the number and asked their IT guys to do show processlist if this happens again. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to save QTextEdit content by QSqlQuery
Op 26-1-2013 0:51, M. Bashir Al-Noimi schreef: Hi guys, I want to save the content of QTextEdit to the database through QSqlQuery... how can I do that? Running textEdit-toHtml() won't work because the returned string has many illegal characters to execute into sql. As long as you use the binding feature of QSqlQuery to put your HTML in your query, as opposed to trying to build the sting manually, you should be fine. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt 5 and filesystem
Op 5-1-2013 6:57, Jason H schreef: Why isn't there a proxy? Because these only exist on QGraphicsView (and were not that great an idea there either, for that matter). André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] CSS and Vertical Progress Bar
Op 28-9-2012 0:33, Austin, Alex schreef: I find that if I apply any CSS to a vertical progress bar, any text displayed on the bar becomes horizontal. Is there a CSS rule I need to add to make it vertical again? I certainly know about the QProgressBar:vertical selector, but don't know what rule will rotate the text properly. Sounds like a bug in Qt to me. Text rotation is not a style sheet property. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QLIneEdit Bug still valid ?
Op 17-7-2012 2:51, Constantin Makshin schreef: I can't say for sure, but most probably yes. You'd have to check to see if that does not block the emission of the signal then after the user edited the text. Does anyone know what the signal emission order _should_ be in case where a user edits the line edit, and the validator corrects that input? André On 07/17/2012 04:10 AM, Petric Frank wrote: Hello René, so patching this location to pass false as additional third parameter should fix the issue, right ? regards Petric Am Dienstag, 17. Juli 2012, 01:06:43 schrieb Constantin Makshin: It works incorrectly only when the validator changes the text. The cause is QLineControl::fixup() (src/gui/widgets/qlinecontrol.cpp, line 387) --- it calls QLineControl::internalSetText() with only 2 parameters, omitting the one that controls emission of the textEdited() signal. And since that parameter defaults to 'true', you get what you get. On 07/16/2012 03:38 PM, R. Reucher wrote: On Monday 16 July 2012 09:14:31 Constantin Makshin wrote: Functions you are interested in are (line numbers are taken from the code in the Git repository): src/gui/widgets/qlineedit.cpp, line 383 (QLineEdit::setText) src/gui/widgets/qlinecontrol_p.h, line 213 (QLineControl::setText) src/gui/widgets/qlinecontrol.cpp, line 676 (QLineControl::internalSetText) src/gui/widgets/qlinecontrol.cpp, line 620 (QLineControl::finishChange) Nothing looks wrong there... Yeah, I also recall it was working correctly when I used it last time... However, the example acts wrongly, but it somehow only happens when the validator is set. The attached example (w/o the validator) works correctly. HTH, René ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Where are the USER properties of Qt-provided QObjects documented?
Op 28-6-2012 8:21, Andreas Pakulat schreef: Hi, Am Donnerstag, 28. Juni 2012 schrieb Bo Thorsen : Hi Frank, Den 28-06-2012 06:40, K. Frank skrev: Where in the documentation (not the source code) can I find out which of the properties of a standard Qt QObject class is the designated USER property? You can't find this, and it doesn't matter. You might be able to find it using the QMetaObject introspection, but I guess this is only for designer or something like it. I've never used this property. [...] For some context, from the documentation for The Property System: The USER attribute indicates whether the property is designated as the user-facing or user-editable property for the class. What do you need this for? I don't know what the op needs this for, but KDE's kconfigxt system uses the property to connect widgets and their corresponding config file entry automatically. It is also used for things like QDataWidgetMapper. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTabWidget/QTabBar allowing user to edit tab names
Op 27-6-2012 23:02, Carl Schumann schreef: Qt community. I would like to allow the user to edit tab names in my application, e.g., by right-clicking and then being given a text field to enter the new name. How would this best be done please? Thanks for any help. Perhaps this Qt DevNet forum topic can be of help? http://qt-project.org/forums/viewthread/10390 I once used this approach to create a charm to add this behavior to a QTabBar or QTabWidget, but I cannot share that code as it was proprietary. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Make a flat Model from a hierarchical Model with all children
Op 28-3-2012 8:20, Bo Thorsen schreef: Den 27-03-2012 14:01, André Somers skrev: Op 26-3-2012 18:34, j-p.nu...@nokia.com schreef: I have a hierarchical Model and i want to have a flat Model. Does anyone have an idea on how to do this with an proxy model? Try this:http://www.fioniasoftware.dk/blog/?p=51 Interesting. Not sure why he (Bo) didn't just replace the view with a QTreeView though? Seems simpler... Hehe, you're missing the next level - the view classes are not the only ones that can use the models :) I use this to choose items in a tree model with a combo box. QComboBox can take a model to deliver the items in it. But tree models have parents and usually multiple columns. The flat proxy can make a single item with the text of each item based on several columns. No, I got that part. My point was (or was supposed to be) that QComboBox can also display a tree directly, if you use it's setView method and set a tree view there. For easy use, you'd only need to confine the tree to a single column, but the parent/child relationship does not need to be removed for that. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Does it really worth it?
Op 28-3-2012 1:13, STEFANI Mathieu schreef: Right, KDChart is available in both GPL and commercial license, see https://customers.kdab.com/ :) But, you'll have to admit, that KDAB is not really all that clear on its site on the option that you can also use GPL. I found it out only when I downloaded 'demo' code (after creating a login). When I inspected it, the headers told me it was under GPL licence. Still, once you figure it out, it's a nice set of components. André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Qt is good because...
Op 26-3-2012 23:24, Quim Gil schreef: Hi, http://qt-project.org/wiki/Qt-is-Good Please help creating a list of points explaining why Qt is good compared to other alternatives for application developers. Let’s focus on specifics: contrastable proof points and experiences from developers working in different platforms are greatly appreciated. You can reply here or edit directly the wiki. In any keep I'll do my best keeping all the relevant information in the wiki page. Thank you! The two main points are for me: * The documentation is clearly best-of-breed, and * The API's are generally clear and consistent, making the framework easy to learn and predictable As a bonus: it has a great community around it! :-) André -- Quim ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Logging best practice.
Op 1-12-2011 16:12, Stefano Cordibella schreef: Hi all, is the state of the art use the debug functions (qDebug, qWarning, ...) in conjunction with a custom message handler (qInstallMsgHandler) for log to file system? I found very simple and useful this approach, but I think that a log function with message level is needed (i.e: qMessage() ) for a complete set of logging levels. Anyone else think that we need a new function with message log level? Thanks in advance, Stefano. Did you evaluate Qxt's logging framework? André ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest