Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.9k Posts
  • QMacNativeWidget and Keyboard Input Focus

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • OpenglWidget doesn't work on a high resolution screen

    3
    0 Votes
    3 Posts
    2k Views
    D
    Since this seems like a bug I suggest you file a bug report ("https://bugreports.qt-project.org/":https://bugreports.qt-project.org/). However, bugfixing is going quite slow on special (i.e. not use-case) bugs like this one. You might have to dig into the code of Qt and fix it yourself. If you're lucky it's just some hardcoded update-rect-limit you need to change or the size of a buffer etc.
  • [SELF-SOLVED] QTabBar and QSS

    3
    0 Votes
    3 Posts
    2k Views
    T
    I found solution. In UPD.
  • Error: incomplete type 'QTime' used in nested name specifier[solved]

    4
    0 Votes
    4 Posts
    26k Views
    T
    You are welcome. And if you see error with incomplete type - it's about that something not included.
  • Best way to implement mainwindow with Tabs, Toolbar and main content area

    2
    0 Votes
    2 Posts
    5k Views
    T
    MainWindow > QTabWidget > QToolbar + QWidget > QWebView. Or you can use QTabBar and QStackedWidget)).
  • QAbstractItemModel modification via QUndoCommand issue

    2
    0 Votes
    2 Posts
    2k Views
    S
    The difference in behaviour is only when the QModelIndex is invalid (usually when I am starting with a new document). Not sure why the logic in lines 89-92 (see link to source below) behaves differently when invoked through the undo command, and directly through the model without going through command. http://kenai.com/projects/mongoviewer/sources/svn/content/desktop/trunk/src/model/tree/TreeModel.cpp?rev=89 Adding a reset() as line 93 fixes the issue, but still no idea why the original logic does not work.
  • Variable in javascript to Qt

    2
    0 Votes
    2 Posts
    1k Views
    F
    http://qt-project.org/doc/qt-4.8/qwebframe.html#addToJavaScriptWindowObject This will help you :)
  • System information

    3
    0 Votes
    3 Posts
    2k Views
    G
    Do you want to know what the OS edition is (if so, do you just care about Windows?), or wether your program is running in 32/64 bit mode? Second is easy using QSysInfo::WordSize, for the former you need OS-specific code (uname, Get[Native]SystemInfo, ...)
  • Crash in QDateTime::currentDateTime().toString()

    10
    0 Votes
    10 Posts
    9k Views
    S
    QDateTime is documented as being re-entrant. It requires the C library to be re-entrant to achieve that though. (either by providing the posix thread safe functions or by implementing the standard functions in a thread safe manner)
  • Removing a non empty folder..

    5
    0 Votes
    5 Posts
    2k Views
    B
    its a vry long method .. but i want codes which is easy to understand ..
  • Rubberband selection in QGraphicsScene / QGraphicsView

    6
    0 Votes
    6 Posts
    18k Views
    U
    So your problem is you can either use the drag or the select mode. So you will either have to use drag and implement selection, or use the select mode and implement dragging, or implement both. The big question is whether your mouseMoveEvent is being called while you are dragging. If so, it is not that hard to calculate how close you are to the edges of the window, and if you are within a given threshold, let's say 20 pixels, you either scroll or scale the view. Determining how fast you scroll is so easy I wouldn't even call it an algorithm. Just set a scrollSpeed variable to like 21, and when you cursor is within 20 pixels of a border, just scroll by (scrollSpeed - distanceFromBorder). This way if your mouse is 18 pixels away from the border, your will scroll by 3 pixels, if it is 2 pixels from the border, you will scroll by 19 pixels. Providing a working code sample would take too much time, you should be able to do it yourself, provided mouseMoveEvent is being called while dragging. edit: OK, found some time, here is some very basic and potentially flawed example, enough to get you started. What it does is it tracks the cursor position relative to the center of the view, and once the cursor is within a certain distance of a border (scrollThreshold value) it give you two numbers, ranging from 0 to scrollThreshold depending on how close to the border you are, the closer you are the bigger values you will get, then you simply scroll by PLUS/MINUS those values depending in which region of the view you are in and the direction you want to scroll in. @ //header class MGraphicsView : public QGraphicsView { Q_OBJECT public: MGraphicsView(QGraphicsScene* parent); protected: void mouseMoveEvent(QMouseEvent *event); }; //CPP float scrollThreshold = 30; void clamp(QPointF &value) { if ((value.x() > scrollThreshold) || (value.x() < 0)) value.rx() = 0; else value.rx() = qAbs(value.x() - scrollThreshold); if ((value.y() > scrollThreshold) || (value.y() < 0)) value.ry() = 0; else value.ry() = qAbs(value.y() - scrollThreshold);; } MGraphicsView::MGraphicsView(QGraphicsScene *parent) : QGraphicsView(parent) { setDragMode(QGraphicsView::RubberBandDrag); } void MGraphicsView::mouseMoveEvent(QMouseEvent *event) { QGraphicsView::mouseMoveEvent(event); QPointF loc = event->posF(); QPointF d; if ((loc.x() <= rect().center().x()) && (loc.y() <= rect().center().y())) { //top left d.setX(frameGeometry().left() + loc.x()); d.setY(loc.y()); clamp(d); if (d.x() || d.y()) scrollContentsBy(d.x()/2, d.y()/2); repaint(); } else if ((loc.x() <= rect().center().x()) && (loc.y() > rect().center().y())) { //bottom left d.setX(frameGeometry().left() + loc.x()); d.setY(frameGeometry().bottom() - loc.y() - scrollThreshold); clamp(d); if (d.x() || d.y()) scrollContentsBy(d.x()/2, -(d.y()/2)); repaint(); } else if ((loc.x() > rect().center().x()) && (loc.y() > rect().center().y())) { //bottom right d.setX(frameGeometry().right() - loc.x()); d.setY(frameGeometry().bottom() - loc.y() - scrollThreshold); clamp(d); if (d.x() || d.y()) scrollContentsBy(-(d.x()/2), -(d.y()/2)); repaint(); } else { //top right d.setX(frameGeometry().right() - loc.x()); d.setY(loc.y()); clamp(d); if (d.x() || d.y()) scrollContentsBy(-(d.x()/2), d.y()/2); repaint(); } }@ It does work a little buggy for me. It scrolls correctly but I get painting artefacts and corruption and even thou it scrolls the item remain in the same location after refresh. Don't know if it is a bug in Qt (I wasn't even able to subclass QGraphicsView in 4.8, compiler gave me a ton of errors, with 4.7.4 it is OK) or flaw in this hasty implementation. It should get you started though.
  • Saving rotated QImage

    3
    0 Votes
    3 Posts
    3k Views
    H
    If anyone is interested in the Solution: I now tried to apply the transformation to the pixmap and converted back to QImage and this works!!! I still wonder why exactly this is the case.
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • How to get a child of rootIndex() in QTreeView ?

    2
    0 Votes
    2 Posts
    7k Views
    C
    @ m_model->index(row, column, rootIndex()); @ any good?
  • Clearing a textEdit before printing text to avoid piling text inside it

    2
    0 Votes
    2 Posts
    1k Views
    C
    QTextEdit::clear()
  • Asking user for folder creation in qt through dialog box .

    6
    0 Votes
    6 Posts
    3k Views
    V
    Now that, I appreciate you if you could prefix [SOLVED] to the topic so that others know that this issue is closed.
  • How to : detect network proxies using Qt

    5
    0 Votes
    5 Posts
    13k Views
    A
    Alright thanks again! =)
  • Widget copy problem

    12
    0 Votes
    12 Posts
    7k Views
    X
    Now, i got another pb : because we are in a for loop, no layout is showed at the end. Do you have a solution ? EDIT : In fact, there was no pb : i just forget to copy the code in my overloaded constructor
  • Unicast signal in Qt D-BUS

    2
    0 Votes
    2 Posts
    2k Views
    K
    If somebody interested I have received answer here: http://stackoverflow.com/questions/11019048/selective-d-bus-signal-emitting-from-observer-unicast-signal/11022421#11022421
  • [Solved]QButtonBox translation

    4
    0 Votes
    4 Posts
    4k Views
    P
    thanks, I got it. Qt has done some translations under directory QtSDK/QtSource/4.8.1/translations