Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • QWidget childAt(x, y) method always return NULL [Solved]

    5
    0 Votes
    5 Posts
    6k Views
    A
    Ok, so I solved my problems by ignoring mouse events in the children (the Pixel instances) by calling @event->ignore()@ and have them propagated up the chain to the parent container (the MouseWidget instance).
  • Digital clock (using QTimer) [SOLVED]

    3
    0 Votes
    3 Posts
    3k Views
    0
    Fairly often these problems occur if something is not correctly included, check your .pro file for errors and if you have a main... well if you even use a main function, it would help if you would show the whole code. cheers
  • [Solved]How to create Executable for windows based environment?

    16
    0 Votes
    16 Posts
    6k Views
    S
    [quote author="5mahesh" date="1324629988"] I got my solution. Thank u friends. Within an hours all the Qt based problems are solved here. That's y Qt teams and this forum still rocks...[/quote] I agree. And not only Qt based problems!
  • QSortFilterProxyModel OR connection

    9
    0 Votes
    9 Posts
    4k Views
    0
    Well sounds about right... I Used the "Mysortfilterproxymodel" from the Qt Examples as my first goto... so just for completion some of it is still in here; Mysortfilterproxymodel.h: @ #include <QDate> #include <QSortFilterProxyModel> //! [0] class MySortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: //Example for implementing it(no declarations) : // // myproxy=new MySortFilterProxyModel(); // myproxy->setSourceModel(sourcemodel); // QRegExp regExp("NuMbeR1|Test3122|Dethklok"); // myproxy->setFilterRegExp(regExp); // ui->view->setModel(myproxy); // this implementation will now filter the given rows (not dynamicly given) // after the regular [removed]NuMber1 OR Test3122 etc. etc.) MySortFilterProxyModel(QObject *parent = 0); //these are just included for purposes of completion, //they should be safe to remove. QDate filterMinimumDate() const { return minDate; } void setFilterMinimumDate(const QDate &date); QDate filterMaximumDate() const { return maxDate; } void setFilterMaximumDate(const QDate &date); //thill here not really nessecary protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: bool dateInRange(const QDate &date) const; QDate minDate; QDate maxDate; }; //! [0] #endif @ Mysortfilterproxymodel.cpp: @ #include <QtGui> #include "mysortfilterproxymodel.h" //! [0] MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { } //! [0] //! [1] void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) { minDate = date; invalidateFilter(); } //! [1] //! [2] void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date) { maxDate = date; invalidateFilter(); } //! [2] //! [3] bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { //Depending on how many rows have to be filtered... // 1. add new Indiezes // 2. select the concerned rows // 3.add them to your source model via return(just follow the example below) QModelIndex index0 = sourceModel()->index(sourceRow, 5, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 15, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 0, sourceParent); return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index1).toString().contains(filterRegExp())) && dateInRange(sourceModel()->data(index2).toDate()); } //! [3] //! [4] //! [5] bool MySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { QVariant leftData = sourceModel()->data(left); QVariant rightData = sourceModel()->data(right); //! [4] //! [6] if (leftData.type() == QVariant::DateTime) { return leftData.toDateTime() < rightData.toDateTime(); } else { QRegExp emailPattern = new QRegExp("([\w\.]@[\w\.]*)"); QString leftString = leftData.toString(); if(left.column() == 1 && emailPattern->indexIn(leftString) != -1) leftString = emailPattern->cap(1); QString rightString = rightData.toString(); if(right.column() == 1 && emailPattern->indexIn(rightString) != -1) rightString = emailPattern->cap(1); return QString::localeAwareCompare(leftString, rightString) < 0; } } //! [5] //! [6] //! [7] bool MySortFilterProxyModel::dateInRange(const QDate &date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); } //! [7] @ Hope it helps. Sorry don't have too much time right now(obviously) but if there are other problems I will get to it as soon as possible. I wish you a very happy Christmas and all good things in 2012!
  • Problem with QStringList - bug or feature?

    12
    0 Votes
    12 Posts
    5k Views
    A
    Thanks for the item number, I have found it. The problem is, I think, that Meyers assumes that the remove() operation only invalidates the iterators pointing to that item. Alas, that is not the case for QList. QList (including QStringList) is not a linked list, but basically an array under the hood. So if you remove an item, items around the item removed may shift, thus also invalidating iterators pointing at those items. I am not exactly sure on the implementation details, but I could even imagine that the question which items shift (the ones behind, or the ones before the removed item) depends on the position of the item that was removed for performance reasons. I think that your original approach would probably work just fine on a QLinkedList, which is much closer to the std::list container than QList is in terms of structure.
  • QSqlRelationalTableModel/QDataWidgetMapper and empty model

    6
    0 Votes
    6 Posts
    3k Views
    B
    Have you got this line?: @ mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit); @
  • Compiling an app in windows for linux

    3
    0 Votes
    3 Posts
    3k Views
    sierdzioS
    "compile everywhere" means what it says: compile separately on every platform. This is C++, after all, it has to be compiled. There are ways to compile for other platforms (so called cross-compilation). Qt has public mkspecs, you can find them on Gitorious - they might help. The easiest and most reliable way (remember, that OSes vary VERY significantly, especially when we talk Unix vs. Windows) is to compile on every platform yourself.
  • How can we remove space only from the end of string?

    4
    0 Votes
    4 Posts
    8k Views
    G
    I would go with a regex: @ QString ttt = " Qt . . . ab "; qDebug() << "ttt" << ttt; ttt.replace(QRegExp("\s*$"), ""); qDebug() << "tt2" << ttt; // output: // ttt " Qt . . . ab " // tt2 " Qt . . . ab" @
  • Embedding a keyboard or Keyboard solution for different languages

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Play an FLV file inside an offline Qt App.

    10
    0 Votes
    10 Posts
    6k Views
    B
    Looks like this might help: http://www.videolan.org/press/lgpl-libvlc.html
  • [SOLVED]Problems with transfer

    13
    0 Votes
    13 Posts
    6k Views
    H
    Ok, i finally fugure out what was wrong with my sending file. Problem was in DataStream. Maybe it's a usual way for writing data in array through QDataStream - get starting write with "\0"-symbol, but i swear - it was a mystery for me. One unfortunate symbol in the file beginning was a symbol of the end of a file. His origin isn't known. When was starting data recording in a file, passing a stream, a problem was solved. Here some code. That stream creates an error: @QByteArray sending_file; sendFile->seek(0); quint64 send=0; while(!sendFile->atEnd()) { sending_file=sendFile->readAll(); quint64 partOfFile=sending_file.size(); out<<sending_file; send+= partOfFile; ui->progressBar->setValue(send); }@ And all of that was transform into: @ QByteArray data; QDataStream out(&data, QIODevice::WriteOnly); *** ui->progressBar->setRange(0,sendingfilesize); ui->progressBar->setValue(0); sendFile->seek(0); quint64 send=0; out.device()->seek(0); quint16 sizeOfDataArray= (quint16)(data.size()-sizeof(quint16)); out<<sizeOfDataArray; _sok->write(data); _sok->flush(); out.device()->reset(); data.clear(); while(!sendFile->atEnd()) { data=sendFile->readAll(); quint64 partOfFile=data.size(); send+= partOfFile; ui->progressBar->setValue(send); } _sok->write(data); _sok->flush();@ Down with intermediaries =) Many thanks for that time that you have given to the decision of my problem. Awfully I apologize for the English - has just now seen, I am how much awful him I own. Once again thanks. I will hope it to somebody will help.
  • 0 Votes
    21 Posts
    12k Views
    K
    You are welcome You have the little problems still existing with the different path definitions possible under windows. So, if you have a solution, I appreciate when you share this. Season's greetings
  • Rotate QImage but do not alter size dimensions etc

    10
    0 Votes
    10 Posts
    9k Views
    V
    mlong: Thanks for the warning. I ended up here by google search and saw this topic had false or insufficient response to the problem stated. I kind of answered to myself and others who might be interested about Qt transformations. The more information about Qt is precise and complete, the more frowning I'm willing to accept =)
  • How to run "Network chat client example" in QT demos ?

    3
    0 Votes
    3 Posts
    3k Views
    A
    I am using eclipse so just make the application. Yestrday strange thing happened I removed and downloaded again the application and import the .pro file,then make the application again and now its working corectly but when I gave the command ./network-chat GUI comes up along with the pop up "Launch another instances on local network and start chatting" I am using two terminal for chatting and on both machines same pop up is coming and chatting is also not happening Please tell me what changes i have to do. Thanks Anu
  • Declaring a function from .dll in Qt4

    3
    0 Votes
    3 Posts
    2k Views
    V
    Actually, I know for a fact that these libraries I am trying to use (the dll) is a 32 bit windows API library. This might make this easier??
  • [Solved] Eclipse Integration missing widgets?

    3
    0 Votes
    3 Posts
    2k Views
    M
    Gah! Total newb mistake. Thanks!
  • 0 Votes
    5 Posts
    6k Views
    S
    Moving on. I decided to take a different tact, and maybe now I'm doing it the right way. @ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); PollController *pollController = new PollController(); pollController->setup(1,1000); QThread *pollThread = new QThread(); QObject::connect(pollThread,SIGNAL(started()),pollController,SLOT(startPolling())); pollController->moveToThread(pollThread); pollThread->start(); return a.exec&#40;&#41;; } @ Inside the "pollController" class, I create a new instance of my QTcpSocket logger class when I have data to report to the web server. @ void PollController::msgReceived(QString &msg) { QString host = "web-dev"; int port = 85; //QString msg = "99.00.050.00.12345678.*"; qDebug() << "pollController received signal from analyze:" << msg; //emit(msgToLog(msg)); // Fire up a new logger Logger *logger = new Logger(this); logger->setup(host,port,msg); } @ It seems to work, I just wonder if I'm really doing things correctly now or am I just getting lucky that it's working in testing?
  • Glproxy in QtOpenCL

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Qmake INCLUDEPATH problem

    5
    0 Votes
    5 Posts
    13k Views
    G
    ah, correct. Environment vars are accessed with $$(xxx) and qmake variables with $${xxx}.
  • How to read From Client through server ?

    Locked
    3
    0 Votes
    3 Posts
    1k Views
    EddyE
    closed this one