Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.3k Topics 455.7k Posts
  • How to generate ui_*.h files in Visual Studio

    Unsolved
    9
    0 Votes
    9 Posts
    4k Views
    VRoninV
    @kitfox said in How to generate ui_*.h files in Visual Studio: I don't see anything in there about qmake qmake is the build system used by Qt Creator, it is not used by Visual Studio. Unfortunately I'm not aware of a way to convert a VS project that was not created with the Qt VS Tools to one compatible so I'm afraid you need to rebuild your project from scratch using the Qt template
  • how to minimize the child window

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    jsulmJ
    @Qt-Enthusiast said in how to minimize the child window: is it related to Parent Child relation No it isn't - why should it? @SGaist already pointed out that hiding one window should not automatically hide another one. You can use this hide() method to hide the dialog if you want.
  • How to install and compile libVLC and integrate it in Qt

    Unsolved
    2
    0 Votes
    2 Posts
    350 Views
    jsulmJ
    @another_one https://wiki.videolan.org/Compile_VLC/ What exactly is the current problem?
  • Customize QSpinbox

    Solved
    3
    1 Votes
    3 Posts
    2k Views
    M
    I got the following results. [image: 6616a4ca-07c3-4e17-ab67-970a5c35d17f.png] code is QSpinBox { padding-right: 15px; /* make room for the arrows */ border-color: rgb(0, 0, 0); border-width: 3; } QSpinBox::up-button { subcontrol-origin: border; subcontrol-position: center right; /* position at the top right corner / width: 16px; / 16 + 2*1px border-width = 15px padding + 3px parent border */ border-image: url(:/new/prefix1/icon/up_arrow_disabled.png); border-width: 1px; } QSpinBox::down-button { subcontrol-origin: border; subcontrol-position: center right ; /* position at bottom right corner */ width: 16px; border-image: url(:/new/prefix1/icon/down_arrow_disabled.png) 1; border-width: 1px; border-top-width: 1; border-right-width:20; }
  • QSqlRelationalDelegate's default value

    Solved qt5 qsqltablemodel qsqlrelational qtableview
    6
    0 Votes
    6 Posts
    2k Views
    K
    So my final solution is: class SqlRelationalDelegate : public QSqlRelationalDelegate { Q_OBJECT public: StorageSqlRelationalDelegate(QObject* parent = nullptr) : QSqlRelationalDelegate(parent) {} QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override { editor = QSqlRelationalDelegate::createEditor(parent, option, index); return editor; } void destroyEditor(QWidget* editor, const QModelIndex& index) const override { QSqlRelationalDelegate::destroyEditor(editor, index); this->editor = nullptr; } QWidget* getEditor() const { return editor; } private: mutable QWidget* editor = nullptr; }; ... class TableView : public QTableView { Q_OBJECT public: StorageTableView(QWidget* parent = nullptr) {} void openPersistentEditor(const QModelIndex &index) { QTableView::openPersistentEditor(index); emit persistentEditorOpened(index); } signals: void persistentEditorOpened(const QModelIndex &index); }; ... connect(view, &TableView::persistentEditorOpened, [view] (const QModelIndex& index) { auto model = view->model(); auto delegate = qobject_cast<SqlRelationalDelegate*>(view->itemDelegate(index)); if (!delegate) qFatal("Delegate cast error"); delegate->setModelData(delegate->getEditor(), model, index); });
  • Linking static library built with Qt4 with an app that uses Qt 5

    Unsolved
    3
    0 Votes
    3 Posts
    259 Views
    A
    Thanks a lot for answering the question.
  • 0 Votes
    2 Posts
    996 Views
    O
    Good news everyone! I found a solution. Or rather a workaround, but a simple one at least. It turns out I can easily avoid getting into the issue with local/scene/ignored transforms in the first place. I'm kind of ashamed I did not think about this earlier, but hey at least I can move forward with my project now. Here's the fix. Instead of parenting the QGraphicsProxyWidget to a QGraphicsWidget, and explicitly setting the QWidget as proxy target, I get the proxy directly from the QGraphicsScene, letting it set the window flag on the wrapper, and set the ItemIgnoresTransformations flag on the proxy. Then (and here's the workaround) I install an event filter on the proxy, intercept the GraphicsSceneMouseMove event where I force the proxy position to currentPos+mouseDelta (both in scene coordinates). Here's the code sample from above, patched with that solution: import sys import PyQt5 from PyQt5.QtCore import Qt from PyQt5.QtWidgets import * global view global scaleLabel def scaleScene(event): delta = 1.0015**event.angleDelta().y() view.scale(delta, delta) scaleLabel.setPlainText("scale: %.2f"%view.transform().m11()) view.update() class ItemFilter(PyQt5.QtWidgets.QGraphicsItem): def __init__(self, target): super(ItemFilter, self).__init__() self.target = target def boundingRect(self): return self.target.boundingRect() def paint(self, *args, **kwargs): pass def sceneEventFilter(self, watched, event): if watched != self.target: return False if event.type() == PyQt5.QtCore.QEvent.GraphicsSceneMouseMove: self.target.setPos(self.target.pos()+event.scenePos()-event.lastScenePos()) event.setAccepted(True) return True return super(ItemFilter, self).sceneEventFilter(watched, event) if __name__ == '__main__': app = QApplication(sys.argv) # create main widget w = QWidget() w.resize(800, 600) layout = QVBoxLayout() w.setLayout(layout) w.setWindowTitle('Example') w.show() # rescale view on mouse wheel, notice how when view.transform().m11() is not 1, # dragging the subwindow is not smooth on the first mouse move event w.wheelEvent = scaleScene # create scene and view scene = QGraphicsScene() scaleLabel = scene.addText("scale: 1") view = QGraphicsView(scene) layout.addWidget(view) view.show(); button = QPushButton('dummy') proxy = scene.addWidget(button, Qt.Window) proxy.setFlag(PyQt5.QtWidgets.QGraphicsItem.ItemIgnoresTransformations) itemFilter = ItemFilter(proxy) scene.addItem(itemFilter) proxy.installSceneEventFilter(itemFilter) # start app sys.exit(app.exec_()) It solves the isue just as wekll in c++. Hoping this may help someone who's ended up in the same dead end I was :)
  • QFontDatabase doesn't give me a fixed font (LUbuntu 18.10)

    Solved
    4
    0 Votes
    4 Posts
    603 Views
    SGaistS
    Glad you found a workaround and thank for sharing ! You should also add it to the bug report, this might help other people.
  • Use of Unicode in Dynamic Translations related code.

    Solved
    4
    0 Votes
    4 Posts
    779 Views
    VRoninV
    Please read http://doc.qt.io/qt-5/i18n-source-translation.html#using-tr-for-all-literal-text tr can't translate variables, it must be used only with literals P.S. m_text = QObject::tr(text); still doesn't compile, you are using m_text = QObject::tr(text.constData()); but it still can't work
  • Frequent, periodic blank lines in Application Output

    Solved
    5
    0 Votes
    5 Posts
    792 Views
    P
    @aha_1980 I updated to the latest Qt Creator and that seems to have fixed the problem. Thanks!
  • QGraphicsItem transparency issue

    Unsolved
    2
    0 Votes
    2 Posts
    612 Views
    A
    @JoeCFD Try not setting a brush.
  • libssh2 and QT

    Unsolved
    10
    0 Votes
    10 Posts
    4k Views
    Pablo J. RoginaP
    @zemcos said in libssh2 and QT: what is recommended for building binaries for libssh2? I'm afraid I cannot help you here directly, but let me ask you how did you build the library yourself? Could you please provide the full command line/switches/etc you have used? As mentioned before, it's very important that you use the same compiler to build both the supporting libraries and your application. Looking briefly at libssh2 code, it has support for building it with CMake or autotools so you have choices to pick from. In addition, building this library could be considered out of scope for Qt itself...
  • 0 Votes
    1 Posts
    210 Views
    No one has replied
  • Simply Code don't show anything

    Solved
    7
    0 Votes
    7 Posts
    779 Views
    J
    @J.Hilk Thank you very much!! That worked!
  • Read doc and docx files

    Unsolved
    12
    0 Votes
    12 Posts
    3k Views
    JonBJ
    @Mikeeeeee That's fine. Are you actually wanting to get the text word-by-word as you have shown? Just saying: it must be horrendously inefficient compared to getting the whole text, but that's OK if that's how you intend.
  • QComboBox with QTableView, selection or focus problem when combobox items pop up

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    B
    I solved the problem reimplementing the showEvent method of QTableView. This post (link) helped me. I did something like this: class MyTableView : public QTableView { Q_OBJECT public: explicit MyTableView(QWidget *parent=0) : QTableView(parent) {} protected: void showEvent(QShowEvent *e) { if (e->type() == QShowEvent::Show) this->selectRow(this->currentIndex().row()); } }; It worked for me.
  • How to keep aspect ratio of QLabel after QPixmap?

    Unsolved
    6
    0 Votes
    6 Posts
    12k Views
    J.HilkJ
    alright, imagine the following, I'm using qDebug() to print some numbers. qDebug() << "Size of the Label" << m_ui->label_3->size(); QPixmap pix(":/icons/icons/chromeL.png"); qDebug() << "Size of the original Image" << pix.size(); QPixmap pixScaled = pix.scaled( m_ui->label_3->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); //Either pixScaled.width() == label_3->width() or pixScaled.height() == label_3->height() with the companion parameter beeing smaller to guaranty aspec-ratio qDebug() << "Size of the scaled Pixmap" << pixScaled.size(); m_ui->label_3->setPixmap(pixScaled);
  • Ending QDrag prematurely.

    11
    0 Votes
    11 Posts
    4k Views
    S
    I'm facing the same issue.tried every suggestion mentioned in the previous comments.Anyone have any more suggestions?
  • QSerialPort write more than one time, only the first writing can be response

    Unsolved
    3
    0 Votes
    3 Posts
    411 Views
    S
    ok, thank, i will check.
  • Qt for WebAssembly

    Unsolved
    5
    0 Votes
    5 Posts
    834 Views
    jsulmJ
    @LeLev A don't know about Windows support. Qt sources: http://code.qt.io/cgit/qt/qt5.git/