Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Bug in QReadWriteLock Non Recursive

    11
    0 Votes
    11 Posts
    5k Views
    S
    @Peppe: It took me some hours to find out why my code was not behaving like given in the specs when doing unit testing and trying to trigger the deadlock. A non-recursive lock could be useful if one thread can only acquire the lock once to avoid programming bugs (lock the same lock several times from your code and forget to free it the same number of times). Apart from this, if the flag is utterly useless it should definitely be removed. One thing is for sure freeing a lock should never result in freeing several locks, but as far as I know this has never been the case.
  • Using spacebar as a shortcut

    4
    0 Votes
    4 Posts
    2k Views
    G
    Setting a [[Doc:QShortcut]] on the application and/or main window should work too.
  • How to signal qt application

    4
    0 Votes
    4 Posts
    3k Views
    A
    I checked the return value of write function from dll, it is giving return value correctly. Only thing is in my Qt GUI app, I am not getting readyRead() signal.
  • [Solved]Gateway and QProcess

    4
    0 Votes
    4 Posts
    2k Views
    T
    Exactly what I have found to but I dont see where to get the gateway in the QHost-classes
  • QNetworkReply::setReadBufferSize seems ignored in 4.8.0

    2
    0 Votes
    2 Posts
    3k Views
    A
    Just to clarify my problem I isolated the issue to separate example: readtest.h: @#include <QObject> class QNetworkAccessManager; class QNetworkReply; class ReadTest : public QObject { Q_OBJECT public: ReadTest(const char *url); protected: void timerEvent(QTimerEvent *event); private: QNetworkAccessManager *_nam; QNetworkReply *_nrp; }; @ readtest.cpp: @#include <QCoreApplication> #include <QDebug> #include <QNetworkAccessManager> #include <QNetworkReply> #include "readbuff.h" ReadTest::ReadTest(const char *url) { qDebug() << "ReadTest, reading url: " << url; _nam = new QNetworkAccessManager(this); _nrp = _nam->get(QNetworkRequest(QUrl(url))); _nrp->setReadBufferSize(1048576); startTimer(100); } void ReadTest::timerEvent(QTimerEvent *) { qDebug() << "bytesAvailable: " << _nrp->bytesAvailable(); _nrp->readAll(); } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); if (argc > 1) { new ReadTest(argv[1]); app.exec(); } } @ You can run it and pass some url as an command line argument. When it compiled with Qt4.7.4. everything works fine and I see each time not more that 1M data available. When it compiled with Qt4.8.0 I see some huge number which depends only on network bandwidth.
  • Editing Images with QML

    2
    0 Votes
    2 Posts
    2k Views
    C
    To answer my own question: "How to create QML Image Element from a QImage":http://developer.qt.nokia.com/forums/viewthread/1659 I just did not see this in my initial round of searching. :)
  • .ico/cur plugin

    11
    0 Votes
    11 Posts
    6k Views
    T
    Faculties tend to have teachers which -- based on my experience -- are happy to help when asked specific questions. How about taking an .ico, converting it to e.g. png using any graphics application. Then you can have Qt read the png and feed that into your write method. If the output is identical to the original .ico file, then you are done. For the read method you can do something similar: You read the orginal file, compare that to the png.
  • [Solved]QProcess and DHCP

    8
    0 Votes
    8 Posts
    5k Views
    T
    Maybe I did this more complex then it realy needs to be. I simple used this code @void GlobalParams::getMyIP() { QNetworkInterface *inter = new QNetworkInterface(); QList<QNetworkInterface> list = inter->allInterfaces(); for (int i = 0; i < list.size(); ++i) { if (list.at(i).name().startsWith("eth0")) { QNetworkInterface iface = QNetworkInterface::interfaceFromName(list.at(i).name()); QList<QNetworkAddressEntry> entries = iface.addressEntries(); if (!entries.isEmpty()) { QNetworkAddressEntry entry = entries.first(); ip = entry.ip(); netMask = entry.netmask(); gateway = entry.broadcast(); } } } @ But as tou could see my gateway is filled up with the broadcastadress. And thats not what I want. Someone who knows how too get this: I have seen some code but it was not so obvious like this so I would like some simple example if there is one around.
  • [solved] QLocale - with atof - why doesn't it convert "3.3"?

    3
    0 Votes
    3 Posts
    3k Views
    A
    Thanks! It worked using setlocale(..)! @ #include <QtCore/QCoreApplication> //#include <QLocale> #include <locale.h> #include <iostream> #include <cmath> #include <cstdlib> using namespace std; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); setlocale(LC_NUMERIC,"en_US"); cout << "arg[1] : " << argv[1] << endl; cout << "atof(arg): " << atof(argv[1])<<endl; return 0; } @
  • [solved] Return time in UTC with Qt 4.7

    4
    0 Votes
    4 Posts
    3k Views
    T
    Thank you! Richard
  • [solved] deleteLater() ?

    4
    0 Votes
    4 Posts
    10k Views
    T
    Yes it does, :) I was facing a crash after a long button press (deleted the object after timeout) and the issue was probably that there was some action referring to the object active in the queue. Adding delete later solved the issue, and I added a qdebug to the deconstructor just to be sure it is deleted, as so it is. Thank you. Richard
  • Deployment problems on Mac OSX

    16
    0 Votes
    16 Posts
    9k Views
    F
    Thank you very much Volker!
  • 0 Votes
    7 Posts
    5k Views
    K
    Thanks Lukas, your trick worked! As I could understand the thread object belongs to the main application, so the events sent to that object are handled by the main event loop. That explains why the finished() signal was never handled.
  • Find list of special folders in Windows using Qt

    2
    0 Votes
    2 Posts
    3k Views
    L
    "QDesktopServices":http://developer.qt.nokia.com/doc/qt-4.8/qdesktopservices.html#storageLocation For the Windows folder I either would use qgetenv("WINDIR") or native GetWindowsDirectory(). Use QFile or QFileInfo to determine if the directory is writable or not.
  • Qt project developed in Windows not working properly in Unix

    2
    0 Votes
    2 Posts
    1k Views
    F
    Well, as the "documentation":http://developer.qt.nokia.com/doc/qt-4.8/qtabwidget.html#tabsClosable-prop reports for instance in the case of the first line of code, the method setTabsClosable has been introduced since Qt 4.5. You are developing with very different versions of Qt, so the only thing you have to do is either upgrade the Linux library or downgrade the Windows one and develop with the same version.
  • QObject::connect crashing

    5
    0 Votes
    5 Posts
    3k Views
    D
    Okay here is the code: header file for moc file generation @ #pragma once #include <QDockWidget> namespace Ui { class EditToolWidget; } class EditToolImpl : public QObject { Q_OBJECT public: EditToolImpl(QDockWidget& parent); ~EditToolImpl(void); public slots: void colorToolButtonClicked(); private: Ui::EditToolWidget *m_ui; }; @ cpp file that initializes the UI and connects the one slot @ #include "EditToolImpl.h" #include <QColorDialog> #include "generated\ui_editToolDockWidget.h" EditToolImpl::EditToolImpl(QDockWidget& parent) { m_ui = new Ui::EditToolWidget(); m_ui->setupUi(&parent); QObject::connect(m_ui->colorToolButton, SIGNAL(clicked()), this, SLOT(colorToolButtonClicked())); } EditToolImpl::~EditToolImpl(void) { } void EditToolImpl::colorToolButtonClicked() { QColor color; color = QColorDialog::getColor(Qt::green, m_ui->dockWidgetContents, QString("Select Color"), QColorDialog::DontUseNativeDialog); } @ The command to compile the header file: $(SolutionDir)\ThirdParty\Qt\4.8.0\bin\moc.exe -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"$(SolutionDir)\ThirdParty\Qt\4.8.0\include\QtCore" -I"$(SolutionDir)\ThirdParty\Qt\4.8.0\include\QtGui" -I"$(SolutionDir)\ThirdParty\Qt\4.8.0\include" -I"$(SolutionDir)\ThirdParty\Qt\4.8.0\include\ActiveQt" -I"." -I"$(SolutionDir)\ThirdParty\Qt\4.8.0\mkspecs\win32-msvc2010" -D_MSC_VER=1600 -DWIN32 EditToolImpl.h -o generated\moc_EditToolImpl.cpp Generated moc_EditToolImpl.cpp @ /**************************************************************************** ** Meta object code from reading C++ file 'EditToolImpl.h' ** ** Created: Tue Feb 7 19:19:52 2012 ** by: The Qt Meta Object Compiler version 63 (Qt 4.8.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../EditToolImpl.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'EditToolImpl.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_EditToolImpl[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: signature, parameters, type, tag, flags 14, 13, 13, 13, 0x0a, 0 // eod }; static const char qt_meta_stringdata_EditToolImpl[] = { "EditToolImpl\0\0colorToolButtonClicked()\0" }; void EditToolImpl::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); EditToolImpl *_t = static_cast<EditToolImpl *>(_o); switch (_id) { case 0: _t->colorToolButtonClicked(); break; default: ; } } Q_UNUSED(_a); } const QMetaObjectExtraData EditToolImpl::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject EditToolImpl::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_EditToolImpl, qt_meta_data_EditToolImpl, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &EditToolImpl::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *EditToolImpl::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void EditToolImpl::qt_metacast(const char _clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_EditToolImpl)) return static_cast<void>(const_cast< EditToolImpl>(this)); return QObject::qt_metacast(_clname); } int EditToolImpl::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } return _id; } QT_END_MOC_NAMESPACE @ The crash occurs within the connect call indicating that the call to *EditToolImpl::metaObject() is returning NULL data.
  • [SOLVED] How to keep a context menu open

    5
    0 Votes
    5 Posts
    9k Views
    P
    Here is the solution - works like a charm. I install the following eventFilter on all QMenus @ def eventFilter(self, obj, event): if event.type() in [QtCore.QEvent.MouseButtonRelease]: if isinstance(obj, QtGui.QMenu): if obj.activeAction(): if not obj.activeAction().menu(): #if the selected action does not have a submenu #eat the event, but trigger the function obj.activeAction().trigger() return True return super(<my_class_name>, self).eventFilter(obj, event) @
  • 0 Votes
    4 Posts
    14k Views
    D
    I'm running under Qt Creator... I've created a variable QT_PLUGIN_PATH and it works... but I guess it's not the real problem, right? Because it should find my plugins at first, right?
  • Qt3---&gt;qt4 contentsHeight

    1
    0 Votes
    1 Posts
    941 Views
    No one has replied
  • QPixmapCache but for QMovies

    1
    0 Votes
    1 Posts
    965 Views
    No one has replied