Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • Maintaining fixed aspect ratio for a widget

    4
    0 Votes
    4 Posts
    2k Views
    P
    I finally gave up on heightForWidth and am now trying to accomplish this with QResizeEvent. If I re-implement it for the widget, it only controls the resizing of the contents of the sub-window, not the sub-window's frame. When I do it for the sub-window (i.e., in a class inheriting QMdiSubWindow), it has no effect! Someone, please throw me a line; I'm running out of ideas.... [EDIT -- After more testing, I realized that I've got a pointer problem: QMdiArea expects type QMdiSubWindow, so I used an unsafe cast to get it to accept my new class. That means I have a base-class pointer directed at an instance of a derived class, which I think explains why my resize code isn't executing. But I'm not sure how I can get around this. Do I have to re-impement QMdiArea as well?]
  • QComboBox popup

    1
    0 Votes
    1 Posts
    914 Views
    No one has replied
  • QStateMachine and dependent properties

    1
    0 Votes
    1 Posts
    826 Views
    No one has replied
  • How to toggle widget "always on top"

    2
    0 Votes
    2 Posts
    3k Views
    C
    I quickly noticed that i was actually trying to turn it on with the code above. Upon further investigation, I found that the flag I was trying to unset isn't set at all in the first place, so unsetting it obviously didn't help. Is there a 'right way' to set a widget (dialog) to not stay on top?
  • Reading contents from memory

    2
    0 Votes
    2 Posts
    989 Views
    T
    Just access the struct in the same way you do in C.
  • [SOLVED]QGraphicsItem, QMatrix and children

    4
    0 Votes
    4 Posts
    2k Views
    J
    @pedro79 Thanks. You solution works :) . @issam No I haven't. But due to ugly outcome of a scale ( if it's scaled by x twice and once by y, borders etc are extremly ugly as one is thicker than another etc...), I used my solution. Marked as solved. Regards, Jake
  • [Solved] QtSerialPort and threading

    7
    1 Votes
    7 Posts
    11k Views
    JKSHJ
    Good to hear :) Please edit your original post and add "[Solved]" to the title
  • Qt Layout problem

    5
    0 Votes
    5 Posts
    2k Views
    L
    Hi Gerolf, could you explain what exactly you mean by custom positioning? Thanks
  • 0 Votes
    4 Posts
    2k Views
    R
    Yes that's it, and only re-enable it once an actual read or an actual write occurs. You can easily do in the proper read/write methods.
  • SetIcon for QTreeWidgetItem

    2
    0 Votes
    2 Posts
    3k Views
    A
    In second code I replace @item->setIcon(1,QPixmap(":/Images/New.png"));@ by @item->setIcon(1,QIcon(":/Images/New.png"));@ and now it's begin to work. But what that was ? All these two piece of code is in on class and currently used. Second piece I add after upgrading to MSVS 2010. But even when I change image in first piece(writed in MSVS 2008) to different from resources it still works.
  • Qt QNetworkRequest::RedirectionTargetAttribute can't detect redirection

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • QDir with nameFilters

    3
    0 Votes
    3 Posts
    1k Views
    P
    Try: QFileInfoList QDir::entryInfoList ( Filters filters = NoFilter, SortFlags sort = NoSort ) const; and set filters to: QDir::Files and then You can use filter on file list I'm not sure if this shows files from 'recursive' directories, but might work. rob
  • QSpinBox doesn't emit valueChanged signal when value is 0 [SOLVED]

    3
    0 Votes
    3 Posts
    4k Views
    M
    Your point is right... there is no way to correct the value before leaving the focus out of the spinbox and without interfering with the user... I subclassed the SpinBox and handled the keyboardevents myself to achieve this, in a similar way to your suggestion. Thank you for your answer.
  • If ((parent = newParent)) - seriously?

    3
    0 Votes
    3 Posts
    1k Views
    A
    Thanks. In the meantime, I found that when changing the boundingRect prior to setParentItem, setParentItem fails (the new parent isn't set). I don't understand it, and couldn't even see the issue when debugging. However, setting the boundingRect after setParentItem is good enough for me. Also, setting a new parent that has ItemClipsChildrenToShape set causes repaint issues.
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    K
    If you're working with QThreads for the first time you should have a look at "the new QThread documentation":http://doc-snapshot.qt-project.org/5.0/qthread.html which has been updated for Qt 5. You don't need to use Qt 5 for your code to work like this. The way to work with QThreads as described in the new documentation works with all Qt versions starting from 4.4. Most important thing to consider is: if you can avoid it DO NOT SUBCLASS QTHREAD.
  • Unit Conversion in Table-Model link?

    8
    0 Votes
    8 Posts
    4k Views
    A
    You are right, the class QProxyModel is obsolute, but it's cousins are not. Proxy model is a bit of a generic term. I'd recommend you base your proxy off [[doc:QIdentityProxyModel]] if you're using Qt 4.8 or up, and QSortFilterProxyModel otherwise. I usually #ifdef the base class for such proxies based on the Qt version, so the class will work in either case. If a whole column represents the same PQ, then I'd considder giving that (and the unit) information as a role for the header, as well as as a role for each individual item. The latter may seem a duplication, but it will make it easier to get the PQ and unit if you just have a QModelIndex to your data. In your proxy, you can use the knowledge to set up a simple mapping per column. Perhaps something like this: if the source model for the proxy provides a PQ and unit for the header of a column, use that for all items in that column; if the source model does not provide a PQ and unit for the header, try and see if there is a PQ and unit for the item itself. If so, use that; if not, do not convert. That way, you can set up a default mapping for basically all your data by iterating over the headers of the source model once, avoiding endless calls to find out the PQ and unit for each item every time. However, you're still flexible to change in case you decide that your source data for a particular column is not uniform. For using multiple views on the same data, using proxy models is perfect. You'd give each view its own proxy model, set the unit system on it you want, and set the same base (SI) model on each of the proxies. That way, all views view the same data, just with their units converted. Multiple header rows is going to be complicated to achieve.
  • Solved: time measurement

    12
    0 Votes
    12 Posts
    12k Views
    R
    It works well using utcenter's comment, better than using cv::gettickcount and cv::gettickfrequency in my case. Thanks.
  • MySQL Database Connection Problem on Linux

    6
    1 Votes
    6 Posts
    8k Views
    Q
    hi. my problem is this: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: availabe driver: QSQLITE and I installed. libqt4-sql-mysql but nothing happens I'm working on Ubuntu 11.04. thanks.
  • Is it a bug on QTimeEdit?

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied